Skip to content

Commit

Permalink
Added code Coverage report generation
Browse files Browse the repository at this point in the history
  • Loading branch information
qtkhajacloud committed Feb 23, 2022
1 parent 1865f22 commit 84a4276
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = tests/*
1 change: 1 addition & 0 deletions tests/integration_tests/integration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def basic_test(client,
# Get the specific item
response = client.get(f"{individual_link}/{item_id}")
assert response.status_code == 200
client.put(f"{individual_link}/{item_id}", json=data)
# Delete the specific item
client.delete(f"{individual_link}/{item_id}")
response = client.get(retrieve_link)
Expand Down
46 changes: 46 additions & 0 deletions tests/integration_tests/test_catalog_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,49 @@ def test_catalog_item(client):
unique_field_name='id',
data=new_catalog_item
)


def test_negative_cases_catalog_item(client):
new_catalog_type_json = {"type": "Laptops"}
response = client.post("/api/v1/catalog/types", json=new_catalog_type_json)
catalog_type_id = response.json['id']
new_catalog_brand = {'brand': 'Apple'}
response = client.post("/api/v1/catalog/brands", json=new_catalog_brand)
catalog_brand_id = response.json['id']
# The data with name missing
new_catalog_item = {
'description': '13.3-inch/33.78 cm, Apple M1 chip with 8‑core CPU and 8‑core GPU, 8GB RAM, 512GB SSD',
'price': 131990.00,
'catalog_type_id': catalog_type_id,
'brand_id': catalog_brand_id,
'available_stock': 100,
'max_stock': 500,
'restock_threshold': 10
}
response = client.post("/api/v1/catalog/items", json=new_catalog_item)
assert response.status_code == 400
new_catalog_item = {
'name': 'Apple MacBook Pro',
'description': '13.3-inch/33.78 cm, Apple M1 chip with 8‑core CPU and 8‑core GPU, 8GB RAM, 512GB SSD',
'price': 131990.00,
'catalog_type_id': catalog_type_id,
'brand_id': catalog_brand_id,
'available_stock': 100,
'max_stock': 500,
'restock_threshold': 10
}
response = client.post("/api/v1/catalog/items", json=new_catalog_item)
id = response.json['id']
updated_catalog_item = {
'description': '13.3-inch/33.78 cm, Apple M1 chip with 8‑core CPU and 8‑core GPU, 8GB RAM, 512GB SSD',
'price': 131990.00,
'catalog_type_id': catalog_type_id,
'brand_id': catalog_brand_id,
'available_stock': 1000,
'max_stock': 500,
'restock_threshold': 10
}
response = client.put(f"/api/v1/catalog/items/{id}", json=updated_catalog_item)
assert response.status_code == 400


0 comments on commit 84a4276

Please sign in to comment.