Created
August 15, 2022 16:36
-
-
Save akhundMurad/dd20e384ac02051aadaf4a09b7dcef3c to your computer and use it in GitHub Desktop.
DI with testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def some_func(redis_client) -> dict: | |
| data = redis_client.get(...) | |
| # logic... | |
| return data | |
| class FakeRedisClient: | |
| _storage = dict() | |
| def get(key): | |
| return self._storage[key] | |
| def test_some_func() -> None: | |
| result = some_func(FakeRedisClient()) | |
| assert result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| redis_client = Redis(...) | |
| def some_func() -> dict: | |
| data = redis_client.get(...) | |
| # logic... | |
| return data | |
| def test_some_func() -> None: | |
| # Как мне тут проестить функцию не поднимая редис? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment