def setUpClass(cls): super(Test, cls).setUpClass() hotel = Hotel() hotel.name = 'Park Estique' hotel.country = 'India' hotel.city = 'Mumbai' hotel.street = 'Bajirao Road' hotel.description = 'This is a very good hotel' hotel.telephone_number = 12345 hotel.star_ranking = 4.0 hotel.number_of_rooms = 10 insert_value(hotel)
def test_index_by_stars(self): self.assertEqual(len(DataStore().star_ranking_indexed_data), 0) hotel = Hotel() hotel.name = 'Park Estique' hotel.country = 'India' hotel.city = 'Mumbai' hotel.street = 'Bajirao Road' hotel.description = 'This is a very good hotel' hotel.telephone_number = 12345 hotel.star_ranking = 4.0 hotel.number_of_rooms = 10 insert_value(hotel) index_by_city(hotel) self.assertEqual(len(DataStore().star_ranking_indexed_data), 1)
def build_hotel_object(json_str): ''' :param json_str: ''' hotel_json = json.loads(json_str) hotel = Hotel() hotel.name = str(hotel_json.get("name")) hotel.country = str(hotel_json.get("country")) hotel.city = str(hotel_json.get("city")) hotel.street = str(hotel_json.get("street")) hotel.description = str(hotel_json.get("description")) hotel.telephone_number = str(hotel_json.get("telephone_number")) hotel.star_ranking = int(hotel_json.get("star_ranking")) hotel.number_of_rooms = int(hotel_json.get("number_of_rooms")) return hotel
def setUp(self): self.hotel = Hotel() self.hotel.name = 'Park Estique' self.hotel.country = 'India' self.hotel.city = 'Mumbai' self.hotel.street = 'Bajirao Road' self.hotel.description = 'This is a very good hotel' self.hotel.telephone_number = 12345 self.hotel.star_ranking = 4.0 self.hotel.number_of_rooms = 10
self.boolean_search = BooleanSearch() def test_search_correct_result(self): self.assertEqual( len(self.boolean_search.search("hotel_name", "park AND estique")), 1) def test_search_raises_exception(self): self.assertRaises( AttributeError, lambda: self.boolean_search.search("hotel_name", None)) def test_search_no_result(self): self.assertNotEqual( len(self.boolean_search.search("hotel_name", "park AND estique")), 0) if __name__ == "__main__": #import sys;sys.argv = ['', 'Test.testName'] hotel = Hotel() hotel.name = 'Park Estique' hotel.country = 'India' hotel.city = 'Mumbai' hotel.street = 'Bajirao Road' hotel.description = 'This is a very good hotel' hotel.telephone_number = 12345 hotel.star_ranking = 4.0 hotel.number_of_rooms = 10 insert_value(hotel) unittest.main()
''' Created on Dec 7, 2016 @author: Mahesh.Gurav ''' from models.hotel_details import Hotel from data.data_operations import insert_value, search, delete_value if __name__ == '__main__': hotel = Hotel() hotel.name = 'Park Estique' hotel.country = 'India' hotel.city = 'Mumbai' hotel.street = 'Bajirao Road' hotel.description = 'This is a very good hotel' hotel.telephone_number = 12345 hotel.star_ranking = 4.0 hotel.number_of_rooms = 10 hotel1 = Hotel() hotel1.name = 'Sun And Sand Estique' hotel1.country = 'India' hotel1.city = 'Pune' hotel1.street = 'Shivaji Road' hotel1.description = 'This is a very good hotel with Swimming pool' hotel1.telephone_number = 12345 hotel1.star_ranking = 4.5 hotel1.number_of_rooms = 20 insert_value(hotel)