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)
Beispiel #2
0
 def test_get_all_shop_api(self):
     headers_dict = {'EMAIL': self.user.email}
     shop_1 = create_shop(fk_user_id=self.user.user_id, fk_category_id=self.category.category_id)
     shop_2 = create_shop(fk_user_id=self.user.user_id, fk_category_id=self.category.category_id)
     uri = "/shop"
     user_response = self.app.get(
         uri,
         headers=headers_dict
     )
     self.assertEqual(200, user_response.status_code)
     json_shop = json.loads(user_response.data)
     self.assertEqual(2, len(json_shop))
Beispiel #3
0
 def test_shop_update_api(self):
     headers_dict = {'EMAIL': self.user.email}
     shop_json = self.get_shop_json()
     shop = create_shop(fk_user_id=self.user.user_id, fk_category_id=self.category.category_id)
     shop_json['name'] = 'changed_name'
     shop_json['phone'] = 898989889
     shop_json['address'] = 'some_address'
     shop_json['web_site'] = 'changed_web_site'
     shop_json['shop_profile_banner_url'] = 'changed_url_banner'
     shop_json['shop_profile_image_url'] = 'changed_url_profile'
     uri = "/shop/{shop_id}/update".format(shop_id=shop.shop_id)
     user_response = self.app.post(
         uri,
         data=json.dumps(shop_json),
         content_type="application/json",
         headers=headers_dict
     )
     self.assertEqual(200, user_response.status_code)
     json_user = json.loads(user_response.data)
     self.assertEqual('changed_name', json_user['name'])
     self.assertEqual('changed_web_site', json_user['web_site'])
     self.assertEqual(898989889, json_user['phone'])
     self.assertEqual(shop_json['geo_location'], json_user['geo_location'])
     self.assertEqual(shop_json['shop_profile_banner_url'], json_user['shop_profile_banner_url'])
     self.assertEqual(shop_json['shop_profile_image_url'], json_user['shop_profile_image_url'])
Beispiel #4
0
 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)
Beispiel #5
0
    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 create_offer(offer_hash=None, fk_shop_id=None, fk_category_id=None):
    if offer_hash is None:
        offer_hash = {
                        'title': 'some Titile',
                        'discount': 50.5,
                        'address': "some address",
                        'description': "wow it came now!!!",
                        'offer_profile_banner_url': "some_url_location",
                        'starting_time': datetime.datetime.now(),
                        'end_time': datetime.datetime.now(),
                        'fk_shop_id': create_shop().shop_id if not fk_shop_id else fk_shop_id,
                        'fk_category_id': create_category().category_id if not fk_category_id else fk_category_id,
                        'geo_location': 'somelocation'
                    }
    return Offer.create_offer(offer_hash)
Beispiel #7
0
 def test_get_shop_api(self):
     headers_dict = {'EMAIL': self.user.email}
     shop = create_shop(fk_user_id=self.user.user_id, fk_category_id=self.category.category_id)
     uri = "/shop/{shop_id}".format(shop_id=shop.shop_id)
     user_response = self.app.get(
         uri,
         headers=headers_dict
     )
     self.assertEqual(200, user_response.status_code)
     json_shop = json.loads(user_response.data)
     self.assertEqual(shop.name, json_shop['name'])
     self.assertEqual(shop.phone, json_shop['phone'])
     self.assertEqual(shop.address, json_shop['address'])
     self.assertEqual(shop.web_site, json_shop['web_site'])
     self.assertEqual(shop.shop_profile_banner_url, json_shop['shop_profile_banner_url'])
     self.assertEqual(shop.shop_profile_image_url, json_shop['shop_profile_image_url'])
     self.assertEqual(shop.geo_location, json_shop['geo_location'])
Beispiel #8
0
 def test_should_return_list_of_shop_by_user(self):
     create_shop(fk_user_id=self.user.user_id)
     create_shop(fk_user_id=self.user.user_id)
     create_shop(fk_user_id=self.user.user_id)
     shop = Shop.find_shops_by_user(self.user)
     self.assertEqual(len(shop), 4)
Beispiel #9
0
 def setUp(self):
     super(ShopTest, self).setUp()
     self.user = create_user()
     self.shop = create_shop(fk_user_id=self.user.user_id)