def test_google_sets_query_result_width_to_none_if_missing_height_from_result(self):
     google = Google()
     item = {
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 500,
         }
     }
     query_result = google.extract_query_result(item)
     assert query_result.height == None
Example #2
0
 def test_google_sets_query_result_width_to_none_if_missing_height_from_result(
         self):
     google = Google()
     item = {
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 500,
         }
     }
     query_result = google.extract_query_result(item)
     assert query_result.height == None
 def test_google_can_extract_a_query_result_object_with_width_from_a_result(self):
     google = Google()
     item = {
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 250,
             u'height': 500
         }
     }
     query_result = google.extract_query_result(item)
     assert query_result.width == 250
 def test_google_extracts_one_query_result_from_one_result(self):
     google = Google()
     decoded_response = {u'items': [{
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 250,
             u'height': 250
         }
     }]}
     results = google.convert_result_to_query_result(decoded_response)
     assert len(results) == 1
Example #5
0
 def test_google_can_extract_a_query_result_object_with_width_from_a_result(
         self):
     google = Google()
     item = {
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 250,
             u'height': 500
         }
     }
     query_result = google.extract_query_result(item)
     assert query_result.width == 250
Example #6
0
 def test_google_limits_results_to_five(self):
     google = Google()
     item = {
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 250,
             u'height': 250
         }
     }
     items = [item] * 100
     decoded_response = {u'items': items}
     results = google.convert_result_to_query_result(decoded_response)
     assert len(results) == 5
Example #7
0
 def test_google_extracts_one_query_result_from_one_result(self):
     google = Google()
     decoded_response = {
         u'items': [{
             u'link': 'http://logo.com/logo.png',
             u'image': {
                 u'width': 250,
                 u'height': 250
             }
         }]
     }
     results = google.convert_result_to_query_result(decoded_response)
     assert len(results) == 1
 def test_google_limits_results_to_five(self):
     google = Google()
     item = {
         u'link': 'http://logo.com/logo.png',
         u'image': {
             u'width': 250,
             u'height': 250
         }
     }
     items = [item] * 100
     decoded_response = {u'items': items}
     results = google.convert_result_to_query_result(decoded_response)
     assert len(results) == 5
Example #9
0
 def test_google_can_extract_a_query_result_object_with_url_from_a_result(
         self):
     google = Google()
     item = {u'link': 'http://logo.com/logo.png'}
     query_result = google.extract_query_result(item)
     assert query_result.url == 'http://logo.com/logo.png'
Example #10
0
 def test_google_extracts_zero_query_results_from_zero_results(self):
     google = Google()
     decoded_response = {u'items': []}
     results = google.convert_result_to_query_result(decoded_response)
     assert len(results) == 0
Example #11
0
 def test_google_generates_a_url_with_query_as_get_parameter(
         self, mock_config):
     mock_config.get.return_value = 'bogus-key'
     google = Google()
     request_url = google.generate_query_url('sopra steria logo')
     assert 'sopra+steria+logo' in request_url
 def test_google_can_extract_a_query_result_object_with_url_from_a_result(self):
     google = Google()
     item = {u'link': 'http://logo.com/logo.png'}
     query_result = google.extract_query_result(item)
     assert query_result.url == 'http://logo.com/logo.png'
 def test_google_extracts_zero_query_results_from_zero_results(self):
     google = Google()
     decoded_response = {u'items': []}
     results = google.convert_result_to_query_result(decoded_response)
     assert len(results) == 0
 def test_google_generates_a_url_with_query_as_get_parameter(self, mock_config):
     mock_config.get.return_value = 'bogus-key'
     google = Google()
     request_url = google.generate_query_url('sopra steria logo')
     assert 'sopra+steria+logo' in request_url