def test_change_extra(self, graph): tag_model = factories.AbstractCreativeWorkFactory( extra=factories.ExtraDataFactory(change=factories.ChangeFactory(), data={ 'testing': { 'Same': 'here', 'Overwrite': 'me', 'Dont touch': 'this one', } })) graph.namespace = 'testing' tag = graph.create( None, 'tag', {'extra': { 'Same': 'here', 'Overwrite': 'you', 'New key': 'here' }}) tag.instance = tag_model assert tag.change == { 'extra': { 'New key': 'here', 'Overwrite': 'you', } }
def test_one_to_one_inverse(self): work = factories.AbstractCreativeWorkFactory( extra=factories.ExtraDataFactory()) assert work.extra is not None assert work.extra_version is not None for model, (count, version_count) in { models.AbstractCreativeWork: (1, 1), models.ExtraData: (1, 1), }.items(): assert model.objects.count() == count assert model.VersionModel.objects.count() == version_count work.extra.delete() for model, (count, version_count) in { models.AbstractCreativeWork: (0, 0), models.ExtraData: (0, 0), }.items(): assert model.objects.count() == count assert model.VersionModel.objects.count() == version_count