def test_downgrade_post_action(self, name, res_path, check, side_effect=None): rollback.os = MagicMock() if side_effect is not None: side_effect(self) asset = MagicMock(resource_path=res_path, download_link='http://host/new/path', content_type='new_type', version='2.0', state='upgrading', old_versions=[ MagicMock(resource_path='old/path', download_link='http://host/old/path', content_type='old_type', version='1.0') ]) downgrade_object = MagicMock(_to_downgrade=asset) rollback.downgrade_asset_pa(downgrade_object) self.assertEquals('old/path', asset.resource_path) self.assertEquals('http://host/old/path', asset.download_link) self.assertEquals('old_type', asset.content_type) self.assertEquals('1.0', asset.version) self.assertEquals([], asset.old_versions) asset.save.assert_called_once_with() check(self)
def test_downgrade_post_action_not_defined(self): class manager: pass rollback.downgrade_asset_pa(manager())
def test_downgrade_post_action_none(self): downgrade_object = MagicMock(_to_downgrade=None) rollback.downgrade_asset_pa(downgrade_object)