def test_change_code(activity): db = DatabaseChooser("a database") assert len(db) == 1 old_key = activity.key[:] activity["code"] = "a new one" assert len(db) == 1 assert get_activity(("a database", "a new one")) with pytest.raises(DoesNotExist): get_activity(old_key)
def test_change_database(activity): db = DatabaseChooser("a database") db2 = DatabaseChooser("another database") db2.write({}) assert len(db2) == 0 assert len(db) == 1 old_key = activity.key[:] assert len(get_activity(old_key).production()) == 1 activity["database"] = "another database" assert len(db) == 0 assert len(db2) == 1 assert get_activity(("another database", "foo")) assert len(get_activity(("another database", "foo")).production()) == 1 with pytest.raises(DoesNotExist): get_activity(old_key)
def test_get_activity_peewee(self): database = Database("a database", "sqlite") database.write( { ("a database", "foo"): { "exchanges": [ { "input": ("a database", "foo"), "amount": 1, "type": "production", } ], "location": "bar", "name": "baz", }, } ) self.assertTrue(isinstance(get_activity(("a database", "foo")), PWActivity))
def test_get_activity_singlefile(self): database = Database("a database", "singlefile") database.write({ ("a database", "foo"): { 'exchanges': [{ 'input': ("a database", "foo"), 'amount': 1, 'type': 'production', }], 'location': 'bar', 'name': 'baz' }, }) self.assertTrue(isinstance( get_activity(("a database", "foo")), SFActivity )) self.assertTrue(isinstance( Database.get(("a database", "foo")), SFActivity ))