Fakultas Ilmu Komputer UI

Commit cf4e9c3a 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 !4
parents 11a91da4 85b35c4f
Pipeline #68155 passed with stages
in 5 minutes and 48 seconds
# Generated by Django 3.0.7 on 2021-03-27 05:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20201229_1028'),
]
operations = [
migrations.AddField(
model_name='product',
name='unit',
field=models.CharField(default='buah', max_length=200, verbose_name='unit'),
),
]
......@@ -164,6 +164,7 @@ class Product(db_models.Model):
validators=[validators.MinValueValidator(decimal.Decimal('0.01'))],
verbose_name=_('total profit')
)
unit = db_models.CharField(default='buah', max_length=200, verbose_name=_('unit'))
class Meta:
ordering = ['subcategory', 'name', 'code', 'id']
verbose_name = _('product')
......
......@@ -35,7 +35,8 @@ PRODUCT_DATA = {
'description': 'Dummy description.',
'price': '2000',
'stock': 10,
'modal':'1000',
'modal': '1000',
'unit': 'kg',
}
TRANSACTION_DATA = {
......
......@@ -264,7 +264,8 @@ class ProductSerializer(serializers.ModelSerializer):
'modal',
'profit',
'image',
'total_profit'
'total_profit',
'unit'
]
model = models.Product
read_only_fields = ['id', 'code']
......
......@@ -1169,6 +1169,7 @@ class ProductTest(rest_framework_test.APITestCase):
def test_create_product_success(self):
data = seeds.PRODUCT_DATA
data['subcategory']= self.subcategory.id
data['unit'] = 'kg'
response = request(
'POST',
......@@ -1184,6 +1185,7 @@ class ProductTest(rest_framework_test.APITestCase):
def test_create_product_fail(self):
data = dict(seeds.PRODUCT_DATA, subcategory=self.subcategory.id)
data['name'] = None
data['unit'] = None
response = request(
'POST',
'product-list',
......@@ -1200,7 +1202,8 @@ class ProductTest(rest_framework_test.APITestCase):
data = {
'name': 'Dummy',
'price':'4000',
'modal':'2000'
'modal':'2000',
'unit': 'gram'
}
response = request(
'PATCH',
......@@ -1229,6 +1232,7 @@ class ProductTest(rest_framework_test.APITestCase):
))
data = {
'name': '',
'unit': ''
}
response = request(
'PATCH',
......@@ -1239,7 +1243,6 @@ class ProductTest(rest_framework_test.APITestCase):
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
class ShoppingCartTest(rest_framework_test.APITestCase):
def setUp(self):
self.superuser = models.User.objects.create_superuser(**seeds.SUPERUSER_DATA)
......
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