-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Lend-it/93_visualizar_categorias
Solve visualizar categorias #93
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json | ||
import unittest | ||
|
||
from project.tests.base import BaseTestCase | ||
from database_singleton import Singleton | ||
|
||
from project.api.models import Category | ||
|
||
db = Singleton().database_connection() | ||
|
||
|
||
def add_category(name): | ||
category = Category(name) | ||
db.session.add(category) | ||
db.session.commit() | ||
return category | ||
|
||
|
||
class TestProductCategory(BaseTestCase): | ||
def test_get_all_category(self): | ||
add_category("Eletrodomésticos") | ||
add_category("Livros e revistas") | ||
add_category("Eletrônicos") | ||
|
||
with self.client: | ||
response = self.client.get("/product_category") | ||
data = json.loads(response.data.decode()) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertIn("success", data["status"]) | ||
|
||
self.assertIn("Eletrodomésticos", data["data"]["categories"][0]["name"]) | ||
self.assertIn("Livros e revistas", data["data"]["categories"][1]["name"]) | ||
self.assertIn("Eletrônicos", data["data"]["categories"][2]["name"]) |