Skip to content

Commit 59c3c43

Browse files
committed
Refactor test_dsync for more granular test cases
1 parent af19a8d commit 59c3c43

File tree

3 files changed

+142
-125
lines changed

3 files changed

+142
-125
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ extension-pkg-whitelist = [
4949
"pydantic"
5050
]
5151

52+
[tool.pylint.basic]
53+
# No docstrings required for private methods (Pylint default), or for test_ functions.
54+
no-docstring-rgx="^(_|test_)"
55+
5256
[tool.pylint.messages_control]
5357
# Line length is enforced by Black, so pylint doesn't need to check it.
5458
# Pylint and Black disagree about how to format multi-line arrays; Black wins.

tests/unit/conftest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,31 @@ def backend_a():
227227
return dsync
228228

229229

230+
@pytest.fixture
231+
def backend_a_with_extra_models():
232+
"""Provide an instance of BackendA subclass of DSync with some extra sites and devices."""
233+
extra_models = BackendA()
234+
extra_models.load()
235+
extra_site = extra_models.site(name="lax")
236+
extra_models.add(extra_site)
237+
extra_device = extra_models.device(name="nyc-spine3", site_name="nyc", role="spine")
238+
extra_models.get(extra_models.site, "nyc").add_child(extra_device)
239+
extra_models.add(extra_device)
240+
return extra_models
241+
242+
243+
@pytest.fixture
244+
def backend_a_minus_some_models():
245+
"""Provide an instance of BackendA subclass of DSync with fewer models than the default."""
246+
missing_models = BackendA()
247+
missing_models.load()
248+
missing_models.remove(missing_models.get(missing_models.site, "rdu"))
249+
missing_device = missing_models.get(missing_models.device, "sfo-spine2")
250+
missing_models.get(missing_models.site, "sfo").remove_child(missing_device)
251+
missing_models.remove(missing_device)
252+
return missing_models
253+
254+
230255
class ErrorProneSiteA(ErrorProneModel, SiteA):
231256
"""A Site that sometimes throws exceptions."""
232257

0 commit comments

Comments
 (0)