-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
|
||
from country_workspace.models import Household | ||
from country_workspace.workspaces.models import CountryHousehold | ||
|
||
|
||
@pytest.fixture() | ||
def household() -> "CountryHousehold": | ||
from testutils.factories.household import CountryHouseholdFactory, get_hh_fields | ||
|
||
ff = get_hh_fields(None) | ||
ff["size"] = 99 | ||
return CountryHouseholdFactory(flex_fields=ff) | ||
|
||
|
||
def test_last_changes(household: "Household"): | ||
household.flex_fields["size"] = 2 | ||
household.save() | ||
household.refresh_from_db() | ||
assert household.flex_fields["size"] == 2 | ||
assert household.last_changes() == [("change", "size", (99, 2))] | ||
|
||
|
||
def test_diff(household: "Household"): | ||
household.flex_fields["size"] = 11 | ||
household.save() | ||
household.flex_fields["size"] = 12 | ||
household.save() | ||
household.flex_fields["size"] = 13 | ||
household.save() | ||
household.refresh_from_db() | ||
assert household.diff() == [("change", "size", (13, 12))] | ||
assert household.diff(-1) == [("change", "size", (13, 12))] | ||
assert household.diff(-1, -2) == [("change", "size", (13, 12))] | ||
assert household.diff(-2, -3) == [("change", "size", (12, 11))] | ||
assert household.diff(-3, -4) == [("change", "size", (11, 99))] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.