def test_valid_keywords_but_inexistent_should_raise_bad_requset(self, mock_search):
        params = {'keywords': 'keyword_1'}
        
        mock_search.return_value = MockQuery(None)

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

        with self.assertRaises(HTTPBadRequest):
            extract_keywords(request)
Example #2
0
    def test_valid_keywords_but_inexistent_should_raise_bad_requset(
            self, mock_search):
        params = {'keywords': 'keyword_1'}

        mock_search.return_value = MockQuery(None)

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

        with self.assertRaises(HTTPBadRequest):
            extract_keywords(request)
Example #3
0
    def test_valid_keywords_should_return_ids(self, mock_search):
        params = {'keywords': '1234'}
        keyword = factory.KeywordFactory.build()

        mock_search.return_value = MockQuery(keyword)

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

        self.assertEqual(extract_keywords(request), [keyword.keyword_id])
    def test_valid_keywords_should_return_ids(self, mock_search):
        params = {'keywords': '1234'}
        keyword = factory.KeywordFactory.build()
        
        mock_search.return_value = MockQuery(keyword)

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

        self.assertEqual(extract_keywords(request), [keyword.keyword_id])