예제 #1
0
    def test__get_revision_by_timestamp(self):
        timestamp = datetime(2020, 1, 1, 1, 1, 1)

        revision = Revision(id=1,
                            content='hello',
                            timestamp=timestamp,
                            document_id=5)

        document = Document(id=5, title='blah', revisions=[revision])

        assert document.get_revision_by_timestamp(timestamp) == revision
예제 #2
0
    def test__get_revision_by_timestamp_expect_most_recent(self):
        timestamp = datetime(2020, 1, 1, 1, 1, 1)
        timestamp_latest = datetime(2020, 2, 1, 1, 1, 1)
        timestamp_in_between = datetime(2020, 1, 29, 1, 1, 1)

        revision = Revision(id=1,
                            content='hello',
                            timestamp=timestamp,
                            document_id=5)

        revision_latest = Revision(id=2,
                                   content='hello again',
                                   timestamp=timestamp_latest,
                                   document_id=5)

        document = Document(id=5,
                            title='blah',
                            revisions=[revision, revision_latest])

        assert document.get_revision_by_timestamp(
            timestamp_in_between) == revision