def test_update_exist_product_should_response_status_200(self):
     product = ProductFactory.create()
     data = ProductFactory.attributes()
     del data['category']
     del data['brand']
     resp = self.post('/admin/product/' + str(product.id) + '/update', data)
     expect(resp.status_int).to_equal(200)
 def test_get_exist_product_should_response_correct_data(self):
     product = ProductFactory.create()
     resp = self.get('/admin/product/'+str(product.id))
     expect(resp).to_include(product.name)
     expect(resp).to_include(product.sku)
     expect(resp).to_include(unicode(product.category.name))
     expect(resp).to_include(unicode(product.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_update_an_exist_product_should_be_done(self):
     product = ProductFactory.create()
     data = ProductFactory.attributes()
     del data['category']
     del data['brand']
     resp = self.post('/admin/product/' + str(product.id) + '/update', data)
     product.reload()
     expect(product.name).to_equal(data.get('name'))
     expect(product.sku).to_include(data.get('sku'))
     expect(resp).to_include(unicode(data.get('price')))
     expect(resp).to_include(data.get('selling_price'))
     expect(resp).to_include(data.get('discount'))
 def test_delete_exist_product_should_response_status_200(self):
     product = ProductFactory.create()
     resp = self.post('/admin/product/' + str(product.id) + '/delete',{})
     expect(resp.status_int).to_equal(200)
 def test_get_exist_product_should_response_status_200(self):
     product = ProductFactory.create()
     resp = self.get('/admin/product/'+str(product.id))
     expect(resp.status_int).to_equal(200)
 def test_delete_exist_product_should_be_done(self):
     product = ProductFactory.create()
     resp = self.post('/admin/product/' + str(product.id) + '/delete',{})
     expect(len(Product.objects(id=product.id))).to_equal(0)