-
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 #26 from Lend-it/devel
Release - 02/05/2021 - Quicksand v1.2.0
- Loading branch information
Showing
5 changed files
with
143 additions
and
47 deletions.
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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
FAKE_DESCRIPTION = ( | ||
"Queria um Uno emprestado para jogar com meus amigos neste fim de semana!" | ||
) | ||
FAKE_ENDDATE = "2020-09-30 00:00:00.000" | ||
FAKE_ENDDATE = "2021-09-30 00:00:00.000" | ||
FAKE_STARTDATE = "2020-09-12 00:00:00.000" | ||
FAKE_REQUESTER = "[email protected]" | ||
REQUEST_BASE_URL = "/requests" | ||
|
@@ -91,6 +91,81 @@ def test_get_all_requests(self): | |
|
||
self.assertEqual(len(data["data"]["requests"]), 3) | ||
|
||
def test_get_all_available_requests(self): | ||
add_category("Eletrodomésticos") | ||
add_request( | ||
"Banco Imobiliario", | ||
FAKE_STARTDATE, | ||
FAKE_ENDDATE, | ||
"Queria um banco imobiliário emprestado para jogar com meus amigos neste fim de semana!", | ||
FAKE_REQUESTER, | ||
1, | ||
) | ||
add_request( | ||
"Jogo da vida", | ||
FAKE_STARTDATE, | ||
FAKE_ENDDATE, | ||
"Queria um jogo da vida emprestado para jogar com meus amigos neste fim de semana!", | ||
FAKE_REQUESTER, | ||
1, | ||
) | ||
add_request( | ||
"War", | ||
FAKE_STARTDATE, | ||
FAKE_ENDDATE, | ||
"Queria um war emprestado para jogar com meus amigos neste fim de semana!", | ||
FAKE_REQUESTER, | ||
1, | ||
) | ||
|
||
with self.client: | ||
response = self.client.get( | ||
f"{REQUEST_BASE_URL}/available?usermail={FAKE_EMAIL}" | ||
) | ||
data = json.loads(response.data.decode()) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertIn("success", data["status"]) | ||
|
||
self.assertEqual(len(data["data"]["available requests"]), 3) | ||
|
||
def test_not_available_requests(self): | ||
add_category("Eletrodomésticos") | ||
add_request( | ||
"Banco Imobiliario", | ||
FAKE_STARTDATE, | ||
FAKE_ENDDATE, | ||
"Queria um banco imobiliário emprestado para jogar com meus amigos neste fim de semana!", | ||
"[email protected]", | ||
1, | ||
) | ||
add_request( | ||
"Jogo da vida", | ||
FAKE_STARTDATE, | ||
"2021-01-30 00:00:00.000", | ||
"Queria um jogo da vida emprestado para jogar com meus amigos neste fim de semana!", | ||
FAKE_REQUESTER, | ||
1, | ||
) | ||
add_request( | ||
"War", | ||
FAKE_STARTDATE, | ||
FAKE_ENDDATE, | ||
"Queria um war emprestado para jogar com meus amigos neste fim de semana!", | ||
FAKE_REQUESTER, | ||
1, | ||
lender="[email protected]", | ||
) | ||
|
||
with self.client: | ||
response = self.client.get( | ||
f"{REQUEST_BASE_URL}/available?usermail={FAKE_EMAIL}" | ||
) | ||
data = json.loads(response.data.decode()) | ||
|
||
self.assertEqual(response.status_code, 404) | ||
self.assertIn("fail", data["status"]) | ||
|
||
def test_get_all_requests_requester(self): | ||
add_category("Eletrodomésticos") | ||
add_request( | ||
|
@@ -151,8 +226,8 @@ def test_get_all_requests_lender(self): | |
|
||
self.assertEqual(len(data["data"]["requests"]), 1) | ||
|
||
def test_get_filtered_requests(self): | ||
add_category("Eletrodomésticos") | ||
def test_get_requests_filtered_by_category(self): | ||
add_category("Jogos") | ||
add_request( | ||
"Jogo da vida", | ||
FAKE_STARTDATE, | ||
|
@@ -171,7 +246,9 @@ def test_get_filtered_requests(self): | |
) | ||
|
||
with self.client: | ||
response = self.client.get(f"{REQUEST_BASE_URL}/1") | ||
response = self.client.get( | ||
f"{REQUEST_BASE_URL}/available/1?usermail={FAKE_EMAIL}" | ||
) | ||
data = json.loads(response.data.decode()) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
|