def setUp(self): super(CategoryTest, self).setUp() self.category = create_category(title='other') self.category1 = create_category(title='electronics') self.category2 = create_category(title='food') shop_1_hash = { 'name': 'myshop1', 'fk_user_id': create_user(mobile='123456789', email="*****@*****.**").user_id, 'phone': '123456789', 'address': 'some where in india', 'web_site': 'http://www.some_where_in_internet.com', 'shop_profile_banner_url': 'some_url', 'shop_profile_image_url': 'some_url', 'geo_location': 'some_where_in_map', 'fk_category_id': self.category.category_id } shop_2_hash = { 'name': 'myshop', 'fk_user_id': create_user(mobile='987654321', email="*****@*****.**").user_id, 'phone': '123456789', 'address': 'some where in india', 'web_site': 'http://www.some_where_in_internet.com', 'shop_profile_banner_url': 'some_url', 'shop_profile_image_url': 'some_url', 'geo_location': 'some_where_in_map', 'fk_category_id': self.category.category_id } self.shop1 = create_shop(shop_hash=shop_1_hash) self.shop2 = create_shop(shop_hash=shop_2_hash)
def setUp(self): super(ShopControllerTest, self).setUp() create_role('user') create_role('admin') create_role('shop') self.user = create_user() self.category = create_category()
def setUp(self): super(OfferControllerTest, self).setUp() create_role('user') create_role('admin') create_role('offer') self.user = create_user() self.category = create_category() self.shop = create_shop(fk_user_id=self.user.user_id, fk_category_id=self.category.category_id)
def test_get_user_api(self): user_json = self.get_user_json() user = create_user(user_json) uri = "/user/{user_id}".format(user_id=user.user_id) user_response = self.app.get(uri) self.assertEqual(200, user_response.status_code) json_user = json.loads(user_response.data) self.assertEqual(user_json['name'], json_user['name']) self.assertEqual(user_json['email'], json_user['email']) self.assertEqual(user_json['mobile'], json_user['mobile']) self.assertEqual(user_json['about'], json_user['about']) self.assertEqual(user_json['geo_location'], json_user['geo_location'])
def create_shop(shop_hash=None, fk_user_id=None, fk_category_id=None): if shop_hash is None: shop_hash = { 'name': 'myshop', 'phone': '123456789', 'address': 'some where in india', 'web_site': 'http://www.some_where_in_internet.com', 'shop_profile_banner_url': 'some_url', 'shop_profile_image_url': 'some_url', 'fk_user_id': create_user().user_id if not fk_user_id else fk_user_id, 'geo_location': 'some_where_in_map', 'fk_category_id': create_category().category_id if not fk_category_id else fk_category_id } return Shop.create_shop(shop_hash)
def test_user_update_api(self): user_json = self.get_user_json() user = create_user(user_json) user_json['name'] = 'changed_name' user_json['email'] = '*****@*****.**' user_json['mobile'] = '898989898899' uri = "/user/{user_id}/update".format(user_id=user.user_id) user_response = self.app.post( uri, data=json.dumps(user_json), content_type="application/json", ) self.assertEqual(200, user_response.status_code) json_user = json.loads(user_response.data) self.assertEqual('changed_name', json_user['name']) self.assertEqual('*****@*****.**', json_user['email']) self.assertEqual('898989898899', json_user['mobile']) self.assertEqual(user_json['about'], json_user['about']) self.assertEqual(user_json['geo_location'], json_user['geo_location'])
def test_get_home_api(self): user_json = self.get_user_json() user = create_user(user_json) headers_dict = {'EMAIL': user.email} shop_1 = create_shop(fk_user_id=user.user_id, fk_category_id=self.category.category_id) shop_2 = create_shop(fk_user_id=user.user_id, fk_category_id=self.category.category_id) uri = "/user/{user_id}/home".format(user_id=user.user_id) home_response = self.app.get( uri, headers=headers_dict ) self.assertEqual(200, home_response.status_code) json_home = json.loads(home_response.data) home = { 'banners': [], 'shops': dumps([shop.as_json() for shop in Shop.find_shops_by_user(user=user)]), 'offers': [], 'recommended': [], 'recent_view': [], } self.assertEqual(dumps(home), dumps(json_home))
def setUp(self): super(UserTest, self).setUp() self.user = create_user()
def setUp(self): super(ShopTest, self).setUp() self.user = create_user() self.shop = create_shop(fk_user_id=self.user.user_id)