def test__update_to_3_0_0(self, fixtures_dir): with open(os.path.join(fixtures_dir, "default_setup_2_6_0.json")) as file: setup = json.load(file) setup = SetupUpdater._update_to_3_0_0(setup) with open(os.path.join(fixtures_dir, "default_setup_3_0_0.json")) as file: fixture_3_0_0 = json.load(file) assert setup == fixture_3_0_0
def test__update_to_3_1_0(self, fixtures_dir): with open(os.path.join(fixtures_dir, "default_setup_3_0_0.json")) as file: setup = json.load(file) setup = SetupUpdater._update_to_3_1_0(setup) with open(os.path.join(fixtures_dir, "default_setup_3_1_0.json")) as file: fixture_3_1_0 = json.load(file) assert setup == fixture_3_1_0 SetupValidator().validate( setup ) # this only could be applied to the last version update test
def test_update_2_3_2(self): with mock.patch( "backend.devices.setup_updater.SetupUpdater._update_to_2_4_0", return_value={"version": "2.4.0"}, ) as m__update_to_2_4_0, mock.patch( "backend.devices.setup_updater.SetupUpdater._update_to_2_5_0" ) as m__update_to_2_5_0: SetupUpdater().update({"version": "2.3.2"}) assert m__update_to_2_4_0.called is True assert m__update_to_2_5_0.called is True
def test_update_3_1_0(self): assert SetupUpdater().update({"version": "3.1.0"}) == {"version": "3.1.0"}
def test_update_3_0_0(self): with mock.patch( "backend.devices.setup_updater.SetupUpdater._update_to_3_1_0" ) as m__update_to_3_1_0: SetupUpdater().update({"version": "3.0.0"}) assert m__update_to_3_1_0.called is True
def _update(setup): """Update to the last version if necessary""" return SetupUpdater().update(setup)