Exemplo n.º 1
0
 def test_p_all_filter_sell(self):
     product = Product.objects.last()
     urls = reverse("product-all")
     filters = "%s?sell=%s" % (urls, product.sell)
     response = self.e.get(filters, content_type='application/json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     logger.info("Get all product with filter sell - %s" % response.data)
Exemplo n.º 2
0
 def test_c_destroy(self):
     category = Category.objects.first()
     payload = api_settings.JWT_PAYLOAD_HANDLER
     encode = api_settings.JWT_ENCODE_HANDLER
     token = encode(payload(category.user.user))
     urls = reverse('category-detail', args=[category.id])
     self.e.credentials(HTTP_AUTHORIZATION="Bearer " + token)
     response = self.e.delete(urls, content_type='application/json')
     message = _("Category has been deleted")
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data, {'message': message})
     logger.info(message)
Exemplo n.º 3
0
 def test_p_destroy(self):
     product = Product.objects.first()
     urls = reverse("product-detail", args=[product.id])
     payload = api_settings.JWT_PAYLOAD_HANDLER
     encode = api_settings.JWT_ENCODE_HANDLER
     token = encode(payload(product.author.user))
     self.e.credentials(HTTP_AUTHORIZATION="Bearer " + token)
     response = self.e.delete(urls, content_type='application/json')
     message = _("Product has been deleted")
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data, {'message': message})
     logger.info(message)
Exemplo n.º 4
0
 def test_c_update(self):
     category = Category.objects.first()
     urls = reverse('category-update', args=[category.id])
     data = {
         'name': fake.name(),
         'icon': File(open("prefix/1599307724_Attack-On-Titan-Season-4-Every-Detail.jpeg", "rb")),
     }
     payload = api_settings.JWT_PAYLOAD_HANDLER
     encode = api_settings.JWT_ENCODE_HANDLER
     token = encode(payload(category.user.user))
     self.e.credentials(HTTP_AUTHORIZATION="Bearer " + token)
     response = self.e.post(urls, data)
     message = _("Category has been updated")
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data, {'message': message})
     logger.info(message)
Exemplo n.º 5
0
 def test_c_create(self):
     urls = reverse('category-list')
     decode = api_settings.JWT_DECODE_HANDLER
     token = readme.get('token')
     user = decode(token)
     data = {
         'name': fake.name(),
         'icon': File(open("prefix/1599307724_Attack-On-Titan-Season-4-Every-Detail.jpeg", "rb")),
         "user": user.get('user_id')
     }
     self.e.credentials(HTTP_AUTHORIZATION="Bearer " + token)
     response = self.e.post(urls, data)
     message = _("Category has been created")
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(response.data, {'message': message})
     logger.info(message)
Exemplo n.º 6
0
 def test_p_update(self):
     product = Product.objects.first()
     urls = reverse('product-update', args=[product.id])
     payload = api_settings.JWT_PAYLOAD_HANDLER
     encode = api_settings.JWT_ENCODE_HANDLER
     token = encode(payload(product.author.user))
     data = {
         'name': fake.name(),
         'photo': File(open("prefix/1599307724_Attack-On-Titan-Season-4-Every-Detail.jpeg", "rb")),
         'sell': fake.random_number(),
         'promo': fake.random_number(),
         'agent': fake.random_number(),
         'description': fake.text(),
     }
     self.e.credentials(HTTP_AUTHORIZATION="Bearer " + token)
     response = self.e.post(urls, data)
     message = _("Product has been updated")
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data, {'message': message})
     logger.info(message)
Exemplo n.º 7
0
 def test_p_create(self):
     category = Category.objects.last()
     urls = reverse('product-list')
     payload = api_settings.JWT_PAYLOAD_HANDLER
     encode = api_settings.JWT_ENCODE_HANDLER
     token = encode(payload(category.user.user))
     data = {
         'name': fake.name(),
         'photo': File(open("prefix/1599307724_Attack-On-Titan-Season-4-Every-Detail.jpeg", "rb")),
         'sell': fake.random_number(),
         'promo': fake.random_number(),
         'agent': fake.random_number(),
         'description': fake.text(),
         'category': category.id,
         'author': category.user.id
     }
     self.e.credentials(HTTP_AUTHORIZATION="Bearer " + token)
     response = self.e.post(urls, data)
     message = _("Product has been created")
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(response.data, {"message": message})
     logger.info(message)
Exemplo n.º 8
0
 def test_c_retrieve(self):
     category = Category.objects.first()
     urls = reverse('category-detail', args=[category.id])
     response = self.e.get(urls, content_type='application/json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     logger.info("Get detail category")
Exemplo n.º 9
0
 def test_c_list(self):
     urls = reverse("category-list")
     response = self.e.get(urls, content_type='application/json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     logger.info("Get all category")
Exemplo n.º 10
0
 def test_p_all(self):
     urls = reverse("product-all")
     response = self.e.get(urls, content_type='application/json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     logger.info("Get all product from generic")
Exemplo n.º 11
0
 def test_p_retrieve(self):
     product = Product.objects.first()
     urls = reverse("product-detail", args=[product.id])
     response = self.e.get(urls, content_type='application/json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     logger.info('Get detail product')