예제 #1
0
    def test_obj_versioning(self, session, obj_payload):
        """Test object versioning."""
        # We will create a new object, so change the id from the payload
        payload = obj_payload
        obj_id = 'fc1ceab8-6c2a-4b19-8f96-cf8c6e56ca88'
        payload['id'] = obj_id
        # Create the object using a new transaction
        self.model.create(payload)
        transaction.commit()
        obj = models.Image.get(obj_id)
        obj_source_path = obj.source_path
        obj = models.Image.get(obj_id)

        assert count_versions(obj) == 1
        assert obj.version == 0

        # now we change the source_path using a new transaction
        obj.source_path = 'foo_bar.jpg'
        transaction.commit()

        obj = self.model.get(obj_id)
        assert obj.version == 1
        assert count_versions(obj) == 2
        assert obj.source_path == 'foo_bar.jpg'
        assert obj.versions[0].source_path != 'foo_bar.jpg'
        assert obj.versions[0].source_path == obj_source_path
예제 #2
0
    def version(self) -> int:
        """Return the current version number.

        We are civilised here, so version numbering starts from zero ;-)
        :return: Version number of this object.
        """
        versions = count_versions(self)
        return versions - 1
예제 #3
0
def film_segment_history(id):
    if not has_write_permission(current_user):
        return None, 401

    seg = FilmSegment.query_visible_to_user(current_user).filter(
        FilmSegment.id == id).first_or_404(id)

    history = []
    for version in range(count_versions(seg)):
        history.append(seg.versions[version].changeset)

    return {'history': history}
 def count_versions(model_object):
     from sqlalchemy_continuum.utils import count_versions
     return count_versions(model_object)
 def count_versions(model_object):
     from sqlalchemy_continuum.utils import count_versions
     return count_versions(model_object)
예제 #6
0
 def test_uses_versioning(self, hearing):
     assert count_versions(hearing) == 1