Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Two new tests related to this new feature.
One checking that re-using a token fails.
One checking that uploading failing data does not block the project (can re-upload).
  • Loading branch information
gusmith committed Nov 11, 2019
commit 3d8890b8afde017c1d89bf256b49b589336816db
48 changes: 48 additions & 0 deletions backend/entityservice/tests/test_project_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,51 @@ def test_project_single_party_empty_data_upload(
)
assert r.status_code == 400


def test_project_upload_wrong_authentication(requests, valid_project_params):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can be more specific here. You are testing that you cannot upload twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

expected_number_parties = get_expected_number_parties(valid_project_params)
if expected_number_parties < 2:
# The test is not made for less than two parties
return

new_project_data = requests.post(url + '/projects',
json={
'schema': {},
**valid_project_params
}).json()
update_tokens = new_project_data['update_tokens']

assert len(update_tokens) == expected_number_parties

small_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'testdata/clks_128B_1k.bin')
token_to_reuse = update_tokens[0]
upload_binary_data_from_file(
requests,
small_file_path, new_project_data['project_id'], token_to_reuse, 1000)

upload_binary_data_from_file(
requests,
small_file_path, new_project_data['project_id'], token_to_reuse, 1000, expected_status_code=403)


def test_project_upload_fail_then_works(requests, valid_project_params):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a great name for this test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was inspired :)

expected_number_parties = get_expected_number_parties(valid_project_params)

new_project_data = requests.post(url + '/projects',
json={
'schema': {},
**valid_project_params
}).json()
update_tokens = new_project_data['update_tokens']

assert len(update_tokens) == expected_number_parties

small_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'testdata/clks_128B_1k.bin')
token_to_reuse = update_tokens[0]
upload_binary_data_from_file(
requests,
small_file_path, new_project_data['project_id'], token_to_reuse, 2000, expected_status_code=400)

upload_binary_data_from_file(
requests,
small_file_path, new_project_data['project_id'], token_to_reuse, 1000)