Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yiran li/feature/get v2 testing #193

Merged
merged 22 commits into from
Mar 25, 2024
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
297bb6d
removed redundant get vehicle test
hafizhasyimm Mar 15, 2024
ecbe676
added tests for get unavailability
hafizhasyimm Mar 15, 2024
ace4099
modified a little bit for the status code of errors and the format of…
Mar 19, 2024
badda0d
modified for the start time of the unavailability
Mar 20, 2024
5e70bf9
Improved test cases by adding test user, removed unnecessary tests
hafizhasyimm Mar 23, 2024
285c7fe
slight correction on no_records response.json
hafizhasyimm Mar 23, 2024
69a485b
modified a little bit to fit the test file
Mar 23, 2024
8d876dd
disable not yet implemented feature tests
TaiHaDev Mar 23, 2024
07c69bb
add Github actions pipeline
TaiHaDev Mar 23, 2024
4f2c55d
change pytest.yml github action pipeline
TaiHaDev Mar 23, 2024
647b5e3
delete some unnecessary lines
Mar 23, 2024
6863dff
Merge branch 'fishchimp/feature/test-unavailability-get' of https://g…
Mar 23, 2024
cc290a7
Merge branch 'johnha/feature/testing-environment-db' of https://githu…
Mar 23, 2024
07d3494
modified some merge conflicts
Mar 24, 2024
9d4b9bf
change pytest.yml github action pipeline
TaiHaDev Mar 24, 2024
83c4459
fixing testing configuration
TaiHaDev Mar 24, 2024
8e7be3c
Merge branch 'YiranLI/feature/get-v2-testing' into johnha/feature/tes…
TaiHaDev Mar 24, 2024
acf58f4
change config file (I did that in Yiran Li branch) and comment out te…
TaiHaDev Mar 24, 2024
bba8b67
modified the test cases for get method to fix some issues
Mar 24, 2024
a356675
modified to deal with conflict during merge
Mar 24, 2024
36c6084
modified the comment
Mar 24, 2024
a3093ed
Merge branch 'main' into YiranLI/feature/get-v2-testing
yiranlir Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions tests/functional/test_unavailability_get.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
# def test_get_volunteer_unavailability_success(test_client):
# user_id = 49
# payload_1 = {
# "title": "All Day Event",
# "periodicity": 0,
# "start": "2024-03-02T00:00:00Z",
# "end": "2024-03-02T23:59:59Z"
# }
# test_client.post(f"/v2/volunteers/{user_id}/unavailability",
# json=payload_1
# )
#
# response = test_client.get(f"/v2/volunteers/{user_id}/unavailability")
# assert response.status_code == 200
def test_get_volunteer_unavailability_success(test_client, create_user):
user_id = create_user
payload_1 = {
"title": "All Day Event",
"periodicity": 0,
"start": "2024-05-02T00:00:00Z",
"end": "2024-05-02T23:59:59Z"
}
test_client.post(f"/v2/volunteers/{user_id}/unavailability",
json=payload_1
)
response = test_client.get(f"/v2/volunteers/{user_id}/unavailability")
assert response.status_code == 200



def test_get_volunteer_unavailability_no_records(test_client):
user_id = 48 # Assuming this user has no unavailability records
def test_get_volunteer_unavailability_no_records(test_client, create_user):
user_id = create_user # Assuming this user has no unavailability records
test_client.post(f"/v2/volunteers/{user_id}/unavailability")
response = test_client.get(f"/v2/volunteers/{user_id}/unavailability")
assert response.status_code == 400 # Assuming the endpoint returns a 400 status for no records found
assert response.json == {"message": "No unavailability record found."} # Expected response body for no records



# def test_get_volunteer_unavailability_invalid_user(test_client):
# user_id = -1
# payload = {
# "title": "All Day Event",
# "periodicity": 0,
# "start": "2024-03-02T00:00:00Z",
# "end": "2024-03-02T23:59:59Z"
# }
# test_client.post(f"/v2/volunteers/{user_id}/unavailability",
# json=payload
# )
# response = test_client.get(f"/v2/volunteers/{user_id}/unavailability")
# assert response.status_code == 404 # Assuming the system treats requests for non-existent users as bad requests
# # or not found
# assert response.json == {"message": "User not found"} # Assuming this is the response for an invalid user ID
def test_get_volunteer_unavailability_invalid_user(test_client):
user_id = -1
test_client.environ_base.pop('HTTP_AUTHORIZATION', None)
payload = {
"title": "All Day Event",
"periodicity": 0,
"start": "2024-03-02T00:00:00Z",
"end": "2024-03-02T23:59:59Z"
}
test_client.post(f"/v2/volunteers/{user_id}/unavailability",
json=payload
)
response = test_client.get(f"/v2/volunteers/{user_id}/unavailability")
assert response.status_code == 401 # Assuming the system treats requests for unauthenticated users as unauthorized requests
# assert response.json == {"message": "User not found"} # Assuming this is the response for an invalid user ID
# assert response.json == {'message': "The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required."}
Loading