Skip to content

Commit 18fd148

Browse files
committed
fix message
1 parent 92ec8bd commit 18fd148

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

splitio/client/factory.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,11 @@ def get_factory(api_key, **kwargs):
413413
if _INSTANTIATED_FACTORIES:
414414
if api_key in _INSTANTIATED_FACTORIES:
415415
_LOGGER.warning(
416-
"factory instantiation: You already have %d factories with this API Key. "
416+
"factory instantiation: You already have %d %s with this API Key. "
417417
"We recommend keeping only one instance of the factory at all times "
418418
"(Singleton pattern) and reusing it throughout your application.",
419-
_INSTANTIATED_FACTORIES[api_key]
419+
_INSTANTIATED_FACTORIES[api_key],
420+
'factory' if _INSTANTIATED_FACTORIES[api_key] == 1 else 'factories'
420421
)
421422
else:
422423
_LOGGER.warning(

tests/client/test_factory.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,27 @@ def _make_factory_with_apikey(apikey, *_, **__):
369369
get_factory('some_api_key')
370370
assert _INSTANTIATED_FACTORIES['some_api_key'] == 2
371371
assert factory_module_logger.warning.mock_calls == [mocker.call(
372-
"factory instantiation: You already have %d factories with this API Key. "
372+
"factory instantiation: You already have %d %s with this API Key. "
373373
"We recommend keeping only one instance of the factory at all times "
374374
"(Singleton pattern) and reusing it throughout your application.",
375-
1
375+
1,
376+
'factory'
377+
)]
378+
379+
factory_module_logger.reset_mock()
380+
get_factory('some_api_key')
381+
assert _INSTANTIATED_FACTORIES['some_api_key'] == 3
382+
assert factory_module_logger.warning.mock_calls == [mocker.call(
383+
"factory instantiation: You already have %d %s with this API Key. "
384+
"We recommend keeping only one instance of the factory at all times "
385+
"(Singleton pattern) and reusing it throughout your application.",
386+
2,
387+
'factories'
376388
)]
377389

378390
factory_module_logger.reset_mock()
379391
get_factory('some_other_api_key')
380-
assert _INSTANTIATED_FACTORIES['some_api_key'] == 2
392+
assert _INSTANTIATED_FACTORIES['some_api_key'] == 3
381393
assert _INSTANTIATED_FACTORIES['some_other_api_key'] == 1
382394
assert factory_module_logger.warning.mock_calls == [mocker.call(
383395
"factory instantiation: You already have an instance of the Split factory. "
@@ -390,4 +402,4 @@ def _make_factory_with_apikey(apikey, *_, **__):
390402
factory1.destroy(event)
391403
event.wait()
392404
assert _INSTANTIATED_FACTORIES['some_other_api_key'] == 1
393-
assert _INSTANTIATED_FACTORIES['some_api_key'] == 1
405+
assert _INSTANTIATED_FACTORIES['some_api_key'] == 2

0 commit comments

Comments
 (0)