Ejemplo n.º 1
0
    def test_datetime_gets_encoded(self):
        expected = {'key1': 'value1', 'when': datetime.now()}
        archive_document_version('valid_doc_type', 'valid_key', 2222, expected)

        actual = retrieve_document_version('valid_doc_type', 'valid_key', 2222)

        assert actual['when'] == expected['when'].isoformat()
Ejemplo n.º 2
0
    def test_read_missing(self):
        # make sure there is something in the db...
        archive_document_version('valid_doc_type', 'valid_key1', 888, {'key1': 'value1'})

        # but try to read something completely different
        with pytest.raises(VersioningException):
            retrieve_document_version('valid_doc_type', 'valid_key2', 888)
Ejemplo n.º 3
0
    def test_list_our_writes(self):
        expected = {'key1': 'value1'}
        archive_document_version('valid_doc_type', 'valid_key', 999, expected)
        all_archived = list_document_versions('valid_doc_type', 'valid_key')

        assert expected in all_archived
Ejemplo n.º 4
0
    def test_read_our_writes(self):
        expected = {'key1': 'value1'}
        archive_document_version('valid_doc_type', 'valid_key', 777, expected)
        actual = retrieve_document_version('valid_doc_type', 'valid_key', 777)

        assert actual == expected
Ejemplo n.º 5
0
    def test_duplicate_different_case_id_fails(self):
        archive_document_version('valid_doc_type', 'valid_key', 666, {'does_not': 'matter'})

        with pytest.raises(VersioningException):
            archive_document_version('valid_doc_type', 'VALID_key', 666, {'if_it': 'is_different'})
Ejemplo n.º 6
0
 def test_version_lt_zero_fails(self):
     with pytest.raises(VersioningException):
         archive_document_version('valid_doc_type', 'valid_key', -1, {})
Ejemplo n.º 7
0
 def test_pk_empty_fails(self):
     with pytest.raises(VersioningException):
         archive_document_version('valid_doc_type', '', 1, {})
Ejemplo n.º 8
0
 def test_doc_type_none_fails(self):
     with pytest.raises(VersioningException):
         archive_document_version(None, 'valid_key', 1, {})