-
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 #14 from Lend-it/121_ajudar_solicitação
Solve [US16] - Ajudar Solicitação #121
- Loading branch information
Showing
5 changed files
with
67 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
from project.api.models import Category | ||
|
||
|
||
def get_category_name(requests: list) -> list: | ||
for request in requests: | ||
productcategoryid = request["productcategoryid"] | ||
category = Category.query.filter_by(productcategoryid=productcategoryid).first() | ||
request["categoryname"] = category.name | ||
|
||
return requests |
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 |
---|---|---|
|
@@ -68,3 +68,34 @@ def test_get_all_requests(self): | |
) | ||
self.assertIn("Jogo da vida", data["data"]["requests"][1]["productname"]) | ||
self.assertIn("War", data["data"]["requests"][2]["productname"]) | ||
|
||
def test_update_lender_request(self): | ||
product = add_request( | ||
"Banco Imobiliario", | ||
"2020-09-12 00:00:00.000", | ||
"2020-09-30 00:00:00.000", | ||
"Queria um banco imobiliário emprestado para jogar com meus amigos neste fim de semana!", | ||
"[email protected]", | ||
3, | ||
) | ||
|
||
with self.client: | ||
response = self.client.patch( | ||
f"/requests/{product.requestid}", | ||
data=json.dumps({"lender": "[email protected]"}), | ||
content_type="application/json", | ||
) | ||
|
||
data = json.loads(response.data.decode()) | ||
self.assertIn("[email protected]", data["request"]["lender"]) | ||
|
||
def test_cannot_update_non_existing_request_lender(self): | ||
with self.client: | ||
response = self.client.patch( | ||
"/requests/8d27b6c1-ac8a-4f29-97b0-96cef6938267", | ||
data=json.dumps({"lender": "[email protected]"}), | ||
content_type="application/json", | ||
) | ||
|
||
data = json.loads(response.data.decode()) | ||
self.assertEqual(response.status_code, 404) |