make 'name' unique in space for MealType
make MealType, Unit, Supermarket, Supermarket Category, PropoertyType case insenstive for get_or_create convert unit conversion create serializer to get_or_create behavior enable create duplicate tests for unitconversion and mealtype api
This commit is contained in:
@ -121,25 +121,37 @@ def test_add(arg, request, u1_s2, space_1, u1_s1):
|
||||
assert r.status_code == 404
|
||||
|
||||
|
||||
# TODO make name in space unique
|
||||
# def test_add_duplicate(u1_s1, u1_s2, obj_1):
|
||||
# r = u1_s1.post(
|
||||
# reverse(LIST_URL),
|
||||
# {'name': obj_1.name},
|
||||
# content_type='application/json'
|
||||
# )
|
||||
# response = json.loads(r.content)
|
||||
# assert r.status_code == 201
|
||||
# assert response['id'] == obj_1.id
|
||||
#
|
||||
# r = u1_s2.post(
|
||||
# reverse(LIST_URL),
|
||||
# {'name': obj_1.name},
|
||||
# content_type='application/json'
|
||||
# )
|
||||
# response = json.loads(r.content)
|
||||
# assert r.status_code == 201
|
||||
# assert response['id'] != obj_1.id
|
||||
def test_add_duplicate(u1_s1, u1_s2, obj_1):
|
||||
r = u1_s1.post(
|
||||
reverse(LIST_URL),
|
||||
{
|
||||
'food': {'id': obj_1.food.id, 'name': obj_1.food.name},
|
||||
'base_amount': 100,
|
||||
'base_unit': {'id': obj_1.base_unit.id, 'name': obj_1.base_unit.name},
|
||||
'converted_amount': 100,
|
||||
'converted_unit': {'id': obj_1.converted_unit.id, 'name': obj_1.converted_unit.name}
|
||||
},
|
||||
|
||||
content_type='application/json'
|
||||
)
|
||||
response = json.loads(r.content)
|
||||
assert r.status_code == 201
|
||||
assert response['id'] == obj_1.id
|
||||
|
||||
r = u1_s2.post(
|
||||
reverse(LIST_URL),
|
||||
{
|
||||
'food': {'id': obj_1.food.id, 'name': obj_1.food.name},
|
||||
'base_amount': 100,
|
||||
'base_unit': {'id': obj_1.base_unit.id, 'name': obj_1.base_unit.name},
|
||||
'converted_amount': 100,
|
||||
'converted_unit': {'id': obj_1.converted_unit.id, 'name': obj_1.converted_unit.name}
|
||||
},
|
||||
content_type='application/json'
|
||||
)
|
||||
response = json.loads(r.content)
|
||||
assert r.status_code == 201
|
||||
assert response['id'] != obj_1.id
|
||||
|
||||
|
||||
def test_delete(u1_s1, u1_s2, obj_1):
|
||||
|
Reference in New Issue
Block a user