Example #1
0
    def test_creates_link_with_trial(self, conn):
        document = {
            'id': '5b99281096b311e6a0ecf8165487599c',
            'trial_id': '7b77a80a8e0541aa92a02ef27d45a0ac',
            'name': 'name',
            'type': 'csr',
        }

        writers.write_document(conn, document)

        assert conn['database']['trials_documents'].find_one(
            trial_id=document['trial_id'],
            document_id=document['id']
        )
Example #2
0
    def test_updates_documents_with_same_type_and_url(self, conn):
        document_id = '5b99281096b311e6a0ecf8165487599c'
        document = {
            'id': document_id,
            'name': 'name',
            'type': 'csr',
            'source_url': 'http://example.org',
        }
        writers.write_document(conn, document)

        del document['id']

        new_document_id = writers.write_document(conn, document)

        assert new_document_id == document_id
Example #3
0
    def test_updates_documents_with_same_type_and_file_id(self, conn):
        document_id = '5b99281096b311e6a0ecf8165487599c'
        document = {
            'id': document_id,
            'name': 'name',
            'type': 'csr',
            'file_id': '7e7bee65ba2b4adba3657d88ad1afc3f',
        }
        writers.write_document(conn, document)

        del document['id']

        new_document_id = writers.write_document(conn, document)

        assert new_document_id == document_id
Example #4
0
    def test_updates_fda_documents(self, conn):
        document_id = '5b99281096b311e6a0ecf8165487599c'
        document = {
            'id': document_id,
            'name': 'name',
            'type': 'csr',
            'file_id': '7e7bee65ba2b4adba3657d88ad1afc3f',
            'fda_approval_id': 'd263061170d84b41bcebfb03582e84b9',
        }
        writers.write_document(conn, document)

        del document['id']

        new_document_id = writers.write_document(conn, document)
        assert new_document_id == document_id
Example #5
0
    def test_updates_documents_with_same_type_and_url(self, conn, document_category):
        document_id = '5b99281096b311e6a0ecf8165487599c'
        document = {
            'id': document_id,
            'name': 'name',
            'source_url': 'http://example.org',
            'document_category_id': document_category,
        }
        writers.write_document(conn, document)

        del document['id']

        new_document_id = writers.write_document(conn, document)

        assert uuid.UUID(new_document_id).hex == document_id
Example #6
0
    def test_updates_documents_with_same_type_and_file_id(self, conn, file_fixture, document_category):
        document_id = '5b99281096b311e6a0ecf8165487599c'
        document = {
            'id': document_id,
            'name': 'name',
            'file_id': file_fixture,
            'document_category_id': document_category,
        }
        writers.write_document(conn, document)

        del document['id']

        new_document_id = writers.write_document(conn, document)

        assert uuid.UUID(new_document_id).hex == document_id
Example #7
0
    def test_updates_fda_documents(self, conn, file_fixture, fda_approval, document_category):
        document_id = '5b99281096b311e6a0ecf8165487599c'
        document = {
            'id': document_id,
            'name': 'name',
            'file_id': file_fixture,
            'fda_approval_id': fda_approval,
            'document_category_id': document_category,
        }
        writers.write_document(conn, document)

        del document['id']

        new_document_id = writers.write_document(conn, document)
        assert uuid.UUID(new_document_id).hex == document_id
Example #8
0
    def test_creates_link_with_trial(self, conn, trial, document_category):
        document = {
            'id': '5b99281096b311e6a0ecf8165487599c',
            'trial_id': trial,
            'source_url': 'http://example.com',
            'name': 'name',
            'document_category_id': document_category,
        }

        writers.write_document(conn, document)

        assert conn['database']['trials_documents'].find_one(
            trial_id=document['trial_id'],
            document_id=document['id']
        )
Example #9
0
    def test_skips_document_with_invalid_url(self, conn):
        document = {
            'name': 'name',
            'type': 'type',
            'source_url': 'url',
        }

        assert writers.write_document(conn, document) is None
Example #10
0
    def test_writes_url_only_document(self, conn):
        document = {
            'name': 'name',
            'type': 'type',
            'source_url': 'https://clinicaltrials.gov/ct2/show/results/NCT00486265',
        }

        assert writers.write_document(conn, document) is not None
Example #11
0
    def test_writes_file_only_document(self, conn):
        document = {
            'name': 'name',
            'type': 'csr',
            'file_id': '7e7bee65ba2b4adba3657d88ad1afc3f',
        }

        assert writers.write_document(conn, document) is not None
Example #12
0
    def test_skips_document_with_invalid_url(self, conn, document_category):
        document = {
            'name': 'name',
            'source_url': 'url',
            'document_category_id': document_category,
        }

        assert writers.write_document(conn, document) is None
Example #13
0
    def test_writes_url_only_document(self, conn, document_category):
        document = {
            'name': 'name',
            'source_url': 'https://clinicaltrials.gov/ct2/show/results/NCT00486265',
            'document_category_id': document_category,
        }

        assert writers.write_document(conn, document) is not None
Example #14
0
    def test_writes_file_only_document(self, conn, file_fixture, document_category):
        document = {
            'name': 'name',
            'file_id': file_fixture,
            'document_category_id': document_category,
        }

        assert writers.write_document(conn, document) is not None
Example #15
0
    def test_returns_the_document_id(self, conn, document_category):
        document = {
            'name': 'name',
            'source_url': 'https://clinicaltrials.gov/ct2/show/results/NCT00486265',
            'document_category_id': document_category,
        }

        document_id = writers.write_document(conn, document)

        assert conn['database']['documents'].find_one(id=document_id)
Example #16
0
    def test_returns_the_document_id(self, conn):
        document = {
            'name': 'name',
            'type': 'csr',
            'file_id': '7e7bee65ba2b4adba3657d88ad1afc3f',
            'source_url': 'https://clinicaltrials.gov/ct2/show/results/NCT00486265',
        }

        document_id = writers.write_document(conn, document)

        assert conn['database']['documents'].find_one(id=document_id)
Example #17
0
    def test_updates_existing_document_by_id(self, conn):
        original_document = {
            'id': '5b99281096b311e6a0ecf8165487599c',
            'name': 'name',
            'type': 'csr',
            'source_url': 'http://example.org',
        }
        new_document = {
            'id': original_document['id'],
            'name': 'new name',
            'type': 'results',
        }
        table = conn['database']['documents']
        table.insert(original_document)

        writers.write_document(conn, new_document)

        document = table.find_one(id=original_document['id'])

        assert document['name'] == new_document['name']
        assert document['type'] == new_document['type']
Example #18
0
    def test_updates_existing_document_by_id(self, conn, document_category):
        original_document = {
            'id': '5b99281096b311e6a0ecf8165487599c',
            'name': 'name',
            'source_url': 'http://example.org',
            'document_category_id': document_category,
        }
        new_document = {
            'id': original_document['id'],
            'name': 'new name',
            'source_url': 'http://example.net',
            'document_category_id': document_category,
        }
        table = conn['database']['documents']
        table.insert(original_document)

        writers.write_document(conn, new_document)

        document = table.find_one(id=original_document['id'])

        assert document['name'] == new_document['name']
        assert document['source_url'] == new_document['source_url']