diff --git a/tests/unit/test_activity_parameter_events.py b/tests/unit/test_activity_parameter_events.py index b5c54d97..e6033645 100644 --- a/tests/unit/test_activity_parameter_events.py +++ b/tests/unit/test_activity_parameter_events.py @@ -8,7 +8,13 @@ @bw2test -def test_activity_parameter_revision_expected_format_create(num_revisions): +def test_activity_parameter_revision_expected_format_create(num_revisions, monkeypatch): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") assert not ActivityParameter.select().count() @@ -27,6 +33,17 @@ def test_activity_parameter_revision_expected_format_create(num_revisions): amount=5, data={"foo": "bar"}, ) + + from pprint import pprint + + pprint( + [ + json.load(open(fp)) + for fp in (projects.dataset.dir / "revisions").iterdir() + if fp.stem.lower() != "head" and fp.is_file() + ] + ) + assert dp.id > 1e6 assert num_revisions(projects) == 1 @@ -73,7 +90,13 @@ def test_activity_parameter_revision_expected_format_create(num_revisions): @bw2test -def test_activity_parameter_revision_apply_create(num_revisions): +def test_activity_parameter_revision_apply_create(num_revisions, monkeypatch): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") DatabaseChooser("test-database").register() assert projects.dataset.revision is None diff --git a/tests/unit/test_database_parameter_events.py b/tests/unit/test_database_parameter_events.py index ac80063d..223d01a1 100644 --- a/tests/unit/test_database_parameter_events.py +++ b/tests/unit/test_database_parameter_events.py @@ -1,14 +1,20 @@ import json from bw2data.database import DatabaseChooser -from bw2data.parameters import DatabaseParameter +from bw2data.parameters import DatabaseParameter, Group from bw2data.project import projects from bw2data.snowflake_ids import snowflake_id_generator from bw2data.tests import bw2test @bw2test -def test_database_parameter_revision_expected_format_create(num_revisions): +def test_database_parameter_revision_expected_format_create(num_revisions, monkeypatch): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") assert not DatabaseParameter.select().count() @@ -65,7 +71,13 @@ def test_database_parameter_revision_expected_format_create(num_revisions): @bw2test -def test_database_parameter_revision_apply_create(num_revisions): +def test_database_parameter_revision_apply_create(num_revisions, monkeypatch): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") DatabaseChooser("test-example").register() assert projects.dataset.revision is None diff --git a/tests/unit/test_project_parameter_events.py b/tests/unit/test_project_parameter_events.py index dd90bf5f..9c944c3f 100644 --- a/tests/unit/test_project_parameter_events.py +++ b/tests/unit/test_project_parameter_events.py @@ -1,14 +1,19 @@ import json -from bw2data.database import DatabaseChooser -from bw2data.parameters import ProjectParameter +from bw2data.parameters import Group, ProjectParameter from bw2data.project import projects from bw2data.snowflake_ids import snowflake_id_generator from bw2data.tests import bw2test @bw2test -def test_project_parameter_revision_expected_format_create(num_revisions): +def test_project_parameter_revision_expected_format_create(num_revisions, monkeypatch): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") assert not ProjectParameter.select().count() @@ -59,7 +64,13 @@ def test_project_parameter_revision_expected_format_create(num_revisions): @bw2test -def test_project_parameter_revision_apply_create(num_revisions): +def test_project_parameter_revision_apply_create(num_revisions, monkeypatch): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") projects.dataset.set_sourced() assert projects.dataset.revision is None @@ -355,7 +366,15 @@ def fake_recalculate(ignored=None, signal=True): @bw2test -def test_project_parameter_revision_expected_format_update_formula_parameter_name(num_revisions): +def test_project_parameter_revision_expected_format_update_formula_parameter_name( + num_revisions, monkeypatch +): + def no_signal_save(self, *args, **kwargs): + kwargs["signal"] = False + return super(Group, self).save(*args, **kwargs) + + monkeypatch.setattr(Group, "save", no_signal_save) + projects.set_current("activity-event") assert projects.dataset.revision is None