def test_update_an_exist_category_should_response_status_200(self):
     category = CategoryWithParentFactory.create()
     data = CategoryWithParentFactory.attributes()
     parent = CategoryFactory.create()
     data['parent'] = str(parent['id'])
     resp = self.post('/admin/category/' + str(category.id) + '/update', data)
     expect(resp.status_int).to_equal(200)
 def test_create_product_should_response_status_201(self):
     product = ProductFactory.attributes()
     category = CategoryFactory.create()
     brand = BrandFactory.create()
     product['category'] = category.id
     product['brand'] = brand.id
     resp = self.post('/admin/product/',product)
     expect(resp.status_int).to_equal(201)
 def test_create_a_category_with_parent_should_response_correct_data(self):
     parent = CategoryFactory.create()
     category = CategoryWithParentFactory.attributes()
     category['parent'] =  parent.id
     resp = self.post('/admin/category/', category)
     expect(resp).to_include(category.get('name'))
     expect(resp).to_include(category.get('image'))
     expect(resp).to_include(unicode(category.get('parent')))
 def test_create_product_should_response_correct_data(self):
     product = ProductFactory.attributes()
     category = CategoryFactory.create()
     brand = BrandFactory.create()
     product['category'] = category.id
     product['brand'] = brand.id
     resp = self.post('/admin/product/',product)
     expect(resp).to_include(product['name'])
     expect(resp).to_include(product['sku'])
     expect(resp).to_include(unicode(category.name))
     expect(resp).to_include(unicode(brand.name))
     expect(resp).to_include(unicode(product['price']))
     expect(resp).to_include(str(product['selling_price']))
     expect(resp).to_include(str(product['discount']))
 def test_create_a_category_with_empty_parent_should_response_correct_data(self):
     category = CategoryFactory.attributes()
     resp = self.post('/admin/category/', category)
     expect(resp).to_include(category.get('name'))
     expect(resp).to_include(category.get('image'))
 def test_create_a_category_with_exist_category_name_sould_response_status_400(self):
     category = CategoryWithParentFactory.create()
     data = CategoryFactory.attributes()
     data['name'] = category.name
     resp = self.post('/admin/category/', data)
     expect(resp.status_int).to_equal(400)
 def test_create_a_category_with_not_enough_data_properties_sould_response_status_400(self):
     category = CategoryFactory.attributes()
     del category['name']
     resp = self.post('/admin/category/', category)
     expect(resp.status_int).to_equal(400)
 def test_create_a_category_with_parent_should_response_status_201(self):
     parent = CategoryFactory.create()
     category = CategoryWithParentFactory.attributes()
     category['parent']=parent.id
     resp = self.post('/admin/category/', category)
     expect(resp.status_int).to_equal(201)
 def test_create_a_category_with_empty_parent_should_response_status_201(self):
     category = CategoryFactory.attributes()
     resp = self.post('/admin/category/', category)
     expect(resp.status_int).to_equal(201)
 def test_delete_exist_category_should_be_done(self):
     category = CategoryFactory.create()
     resp = self.post('/admin/category/' + str(category.id) + '/delete',{})
     expect(len(Category.objects(id=category.id))).to_equal(0)