예제 #1
0
    def test_raises_retryable_error_when_flush_fails(self, db_session, merge_data, monkeypatch):
        def err():
            raise sa.exc.IntegrityError(None, None, None)
        monkeypatch.setattr(db_session, 'flush', err)

        with pytest.raises(transaction.interfaces.TransientError):
            document.merge_documents(db_session, merge_data)
예제 #2
0
    def test_merge_documents_deletes_duplicate_documents(self, db_session, merge_data):
        _, duplicate = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert db_session.query(document.Document).get(duplicate.id) is None
예제 #3
0
파일: document_test.py 프로젝트: nlisgo/h
    def test_raises_retryable_error_when_flush_fails(self, db_session, merge_data, monkeypatch):
        def err():
            raise sa.exc.IntegrityError(None, None, None)
        monkeypatch.setattr(db_session, 'flush', err)

        with pytest.raises(transaction.interfaces.TransientError):
            document.merge_documents(db_session, merge_data)
예제 #4
0
    def test_merge_documents_deletes_duplicate_documents(self, db_session, merge_data):
        _, duplicate = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert db_session.query(document.Document).get(duplicate.id) is None
예제 #5
0
    def test_merge_documents_rewires_document_meta(self, db_session, merge_data):
        master, duplicate = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert len(master.meta) == 2
        assert len(duplicate.meta) == 0
예제 #6
0
    def test_merge_documents_rewires_document_meta(self, db_session, merge_data):
        master, duplicate = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert len(master.meta) == 2
        assert len(duplicate.meta) == 0
예제 #7
0
파일: document_test.py 프로젝트: nlisgo/h
    def test_merge_documents_rewires_document_uris(self, db_session, merge_data):
        master, duplicate_1, duplicate_2 = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert len(master.document_uris) == 3
        assert len(duplicate_1.document_uris) == 0
        assert len(duplicate_2.document_uris) == 0
예제 #8
0
    def test_merge_documents_rewires_document_uris(self, db_session, merge_data):
        master, duplicate_1, duplicate_2 = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert len(master.document_uris) == 3
        assert len(duplicate_1.document_uris) == 0
        assert len(duplicate_2.document_uris) == 0
예제 #9
0
파일: document_test.py 프로젝트: nlisgo/h
    def test_merge_documents_deletes_duplicate_documents(self, db_session, merge_data):
        _, duplicate_1, duplicate_2 = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        count = db_session.query(document.Document) \
            .filter(document.Document.id.in_([duplicate_1.id, duplicate_2.id])) \
            .count()

        assert count == 0
예제 #10
0
    def test_merge_documents_deletes_duplicate_documents(self, db_session, merge_data):
        _, duplicate_1, duplicate_2 = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        count = db_session.query(document.Document) \
            .filter(document.Document.id.in_([duplicate_1.id, duplicate_2.id])) \
            .count()

        assert count == 0
예제 #11
0
파일: document_test.py 프로젝트: nlisgo/h
    def test_merge_documents_rewires_annotations(self, db_session, merge_data):
        master, duplicate_1, duplicate_2 = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert 6 == \
            db_session.query(models.Annotation).filter_by(document_id=master.id).count()
        assert 0 == \
            db_session.query(models.Annotation).filter_by(document_id=duplicate_1.id).count()
        assert 0 == \
            db_session.query(models.Annotation).filter_by(document_id=duplicate_2.id).count()
예제 #12
0
    def test_merge_documents_rewires_annotations(self, db_session, merge_data):
        master, duplicate_1, duplicate_2 = merge_data

        document.merge_documents(db_session, merge_data)
        db_session.flush()

        assert 6 == \
            db_session.query(models.Annotation).filter_by(document_id=master.id).count()
        assert 0 == \
            db_session.query(models.Annotation).filter_by(document_id=duplicate_1.id).count()
        assert 0 == \
            db_session.query(models.Annotation).filter_by(document_id=duplicate_2.id).count()
예제 #13
0
    def test_merge_documents_returns_master(self, db_session, merge_data):
        master, _ = merge_data

        merged_master = document.merge_documents(db_session, merge_data)

        assert merged_master == master
예제 #14
0
파일: document_test.py 프로젝트: nlisgo/h
    def test_merge_documents_returns_master(self, db_session, merge_data):
        master, _, _ = merge_data

        merged_master = document.merge_documents(db_session, merge_data)

        assert merged_master == master