From 947c559e25569fb9534908a8a1534de1f555720e Mon Sep 17 00:00:00 2001 From: eagw <87092433+eagw@users.noreply.github.com> Date: Fri, 20 Aug 2021 10:16:03 -0400 Subject: [PATCH] Update test with style improvements Co-authored-by: Jacob Nesbitt --- multinet/api/tests/test_workspace.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/multinet/api/tests/test_workspace.py b/multinet/api/tests/test_workspace.py index 061db27..6c076be 100644 --- a/multinet/api/tests/test_workspace.py +++ b/multinet/api/tests/test_workspace.py @@ -125,22 +125,23 @@ def test_workspace_rest_rename( workspace.set_owner(user) old_name = workspace.name - fake = Faker() - new_name = fake.pystr() - - request_data = { - 'name': new_name, - } + new_name = Faker().pystr() r = authenticated_api_client.put( f'/api/workspaces/{workspace.name}/', - request_data, + { + 'name': new_name, + }, + format='json', ) assert r.status_code == status_code + # Retrieve workspace to ensure it's up to date workspace = Workspace.objects.get(id=workspace.pk) - assert success == (workspace.name == new_name) - assert success != (workspace.name == old_name) + + # Assert name is as expected + expected_name = new_name if success else old_name + assert workspace.name == expected_name @pytest.mark.django_db