Ejemplo n.º 1
0
    def test_invalid_references_should_raise_bad_request(self):
        params = {'pmids': 'invalid_pmid'}

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        with self.assertRaises(HTTPBadRequest):
            extract_references(request)
Ejemplo n.º 2
0
    def test_invalid_references_should_raise_bad_request(self):
        params = {'pmids': 'invalid_pmid'}

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        with self.assertRaises(HTTPBadRequest):
            extract_references(request)
Ejemplo n.º 3
0
    def test_valid_pmids_but_inexistent_should_raise_bad_requset(self, mock_search):
        params = {'pmids': '1234'}
        
        mock_search.return_value = MockQuery(None)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        with self.assertRaises(HTTPBadRequest):
            extract_references(request)
Ejemplo n.º 4
0
    def test_valid_pmids_but_inexistent_should_raise_bad_requset(
            self, mock_search):
        params = {'pmids': '1234'}

        mock_search.return_value = MockQuery(None)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        with self.assertRaises(HTTPBadRequest):
            extract_references(request)
Ejemplo n.º 5
0
    def test_valid_pmids_should_return_reference_ids(self, mock_search):
        params = {'pmids': '1234'}
        reference = factory.ReferencedbentityFactory.build()

        mock_search.return_value = MockQuery(reference)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        self.assertEqual(extract_references(request), [reference.dbentity_id])
Ejemplo n.º 6
0
    def test_valid_pmids_should_return_reference_ids(self, mock_search):
        params = {'pmids': '1234'}
        reference = factory.ReferencedbentityFactory.build()
        
        mock_search.return_value = MockQuery(reference)

        request = testing.DummyRequest(post=params)
        request.context = testing.DummyResource()

        self.assertEqual(extract_references(request), [reference.dbentity_id])