Ejemplo n.º 1
0
 def test_validation_does_not_raise_exception_if_lat_and_lng_not_provided(
         self):
     params = SearchParams()
     params.search_term = 'camera'
     try:
         params.validate()
     except ResourceError:
         assert False
 def test_search_camera_with_brand_london(self, items):
     params = SearchParams()
     params.search_term = 'camera nikon '
     params.lat = locations.get('London', {}).get('lat')
     params.lng = locations.get('London', {}).get('lng')
     result = Item.search(params)
     assert len(result) == 1
     assert result[0].item_name == 'Camera Nikon'
 def test_search_lenses_la(self, items):
     params = SearchParams()
     params.search_term = 'lenses'
     params.lat = locations.get('LA', {}).get('lat')
     params.lng = locations.get('LA', {}).get('lng')
     result = Item.search(params)
     assert len(result) == 2
     assert result[0].item_name == 'Lenses Canon'
     assert result[1].item_name == 'Camera Lenses Canon'
Ejemplo n.º 4
0
 def test_validation_raises_validation_exception_incorrect_lng(self):
     params = SearchParams()
     params.search_term = 'camera'
     params.lat = 51
     params.lng = -200
     with pytest.raises(ResourceError):
         params.validate()
 def get(self):
     params = SearchParams()
     params.import_data(
         raw_data={
             'search_term': self.get_query_argument('searchTerm',
                                                    default=None),
             'lat': self.get_query_argument('lat', default=None),
             'lng': self.get_query_argument('lng', default=None)
         })
     params.validate()
     items = Item.search(params)
     self.write({'result': [item.to_primitive() for item in items]})
Ejemplo n.º 6
0
 def test_search_camera(self, items):
     params = SearchParams()
     params.search_term = 'camera'
     result = Item.search(params)
     assert len(result) == 2
 def test_search_speakers_no_result(self, items):
     params = SearchParams()
     params.search_term = 'speakers samsung'
     result = Item.search(params)
     assert not result