def test_simple(self, change_ids): p = Person(given_name='John', family_name='Doe', change_id=change_ids.get()) p.save() p.given_name = 'Jane' p.change_id = change_ids.get() p.save() assert p.versions.all()[0].given_name == 'Jane' assert p.versions.all()[1].given_name == 'John'
def test_timestamping(share_source, change_ids): p = Person(given_name='John', family_name='Doe', change_id=change_ids.get()) p.save() created, modified = p.date_created, p.date_modified assert (p.date_created - p.date_modified).total_seconds() < 1 p.given_name = 'Jane' p.change_id = change_ids.get() p.save() assert modified < p.date_modified assert created == p.date_created
def test_many_versions(self, change_ids): p = Person(given_name='John', family_name='Doe', change_id=change_ids.get()) p.save() names = ['Jane', 'John', 'Jone', 'Jane', 'James', 'Joe', 'Jim', 'Jack', 'Jacklynn'] for name in names: p.given_name = name p.change_id = change_ids.get() p.save() p.refresh_from_db() assert p.versions.first() == p.version for i, name in enumerate(reversed(['John'] + names)): assert p.versions.all()[i].given_name == name