Example #1
0
    def test_no_results(self):
        r1 = mock.Mock()
        r1.json.return_value = {"responseData": {"results": []}}

        with mock.patch("requests.get") as get:
            get.side_effect = [r1]
            result = receivers.image_search(None, content='img me funny')
            self.assertEqual(result['content'], "There are no images matching 'funny'")
Example #2
0
    def test_simple_image_search(self):
        r1 = mock.Mock()
        r1.json.return_value = {"responseData": {"results": [{"url": "http://localhost/funny.gif"}]}}

        with mock.patch("requests.get") as get:
            get.side_effect = [r1]
            result = receivers.image_search(None, content='img me funny')
            self.assertEqual(result['content'], 'http://localhost/funny.gif')