Fakultas Ilmu Komputer UI

Commit 8a8b9ca8 authored by Azhar Difa Arnanda's avatar Azhar Difa Arnanda 💬
Browse files

Merge branch 'bungamaku/3/tambah-satuan-produk' into 'dev'

PBI-4: Menambahkan kolom satuan pada model Produk

Closes #3

See merge request !8
parents cf4e9c3a 9c4a7129
Pipeline #68646 passed with stages
in 13 minutes and 20 seconds
......@@ -1181,6 +1181,7 @@ class ProductTest(rest_framework_test.APITestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(models.Product.objects.count(), 1)
self.assertEqual(models.Product.objects.get(id=response.data['id']).name, data['name'])
self.assertEqual(models.Product.objects.get(id=response.data['id']).unit, data['unit'])
def test_create_product_fail(self):
data = dict(seeds.PRODUCT_DATA, subcategory=self.subcategory.id)
......@@ -1215,6 +1216,7 @@ class ProductTest(rest_framework_test.APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(models.Product.objects.get(id=product.id).profit,2000)
self.assertEqual(models.Product.objects.get(id=product.id).name, data['name'])
self.assertEqual(models.Product.objects.get(id=product.id).unit, data['unit'])
data = dict(seeds.PRODUCT_DATA, subcategory=self.subcategory.id)
response = request(
'PUT',
......
......@@ -639,6 +639,7 @@ class ProductList(generics.ListCreateAPIView):
modal=serializer.validated_data['modal'],
subcategory=models.Subcategory.objects.get(name=serializer.validated_data['subcategory']),
total_profit=0,
unit=serializer.validated_data['unit'],
image=validated_image
)
product.profit= (product.price - product.modal)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment