Repository: medtagger/MedTagger

Issue:
Incorrect usage of slashes
## Current Behavior

MedTagger services incorrectly use slashes at the end of namespaces making it incorrect according to REST practises. E.g endpoint for returning all scans looks like this:

`GET /api/v1/scans/`

## Expected Behavior

MedTagger services should not use slashes at the end of namespaces. E.g endpoint for returning all scans should look like this:

`GET /api/v1/scans`


Discussion:

Resolving patch:
diff --git a/backend/medtagger/api/scans/service_rest.py b/backend/medtagger/api/scans/service_rest.py
--- a/backend/medtagger/api/scans/service_rest.py
+++ b/backend/medtagger/api/scans/service_rest.py
@@ -17,7 +17,7 @@
 scans_ns = api.namespace('scans', 'Methods related with scans')
 
 
-@scans_ns.route('/')
+@scans_ns.route('')
 class Scans(Resource):
     """Endpoint that can create new scan."""
 
diff --git a/backend/medtagger/api/users/service.py b/backend/medtagger/api/users/service.py
--- a/backend/medtagger/api/users/service.py
+++ b/backend/medtagger/api/users/service.py
@@ -14,7 +14,7 @@
 users_ns = api.namespace('users', 'Users management')
 
 
-@users_ns.route('/')
+@users_ns.route('')
 class GetUsers(Resource):
     """Get all users endpoint."""
 


Test patch:
diff --git a/backend/tests/functional_tests/test_adding_new_label.py b/backend/tests/functional_tests/test_adding_new_label.py
--- a/backend/tests/functional_tests/test_adding_new_label.py
+++ b/backend/tests/functional_tests/test_adding_new_label.py
@@ -26,7 +26,7 @@ def test_add_brush_label(prepare_environment: Any, synchronous_celery: Any) -> N
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -81,7 +81,7 @@ def test_add_point_label(prepare_environment: Any, synchronous_celery: Any) -> N
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -132,7 +132,7 @@ def test_add_chain_label(prepare_environment: Any, synchronous_celery: Any) -> N
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -195,7 +195,7 @@ def test_add_chain_label_not_enough_points(prepare_environment: Any, synchronous
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -239,7 +239,7 @@ def test_add_label_with_tag_from_other_task(prepare_environment: Any, synchronou
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
diff --git a/backend/tests/functional_tests/test_basic_flow.py b/backend/tests/functional_tests/test_basic_flow.py
--- a/backend/tests/functional_tests/test_basic_flow.py
+++ b/backend/tests/functional_tests/test_basic_flow.py
@@ -38,7 +38,7 @@ def test_basic_flow(prepare_environment: Any, synchronous_celery: Any) -> None:
 
     # Step 3. Add Scan to the system
     payload = {'dataset': dataset_key, 'number_of_slices': 1}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -162,7 +162,7 @@ def test_basic_flow_with_predefined_label(prepare_environment: Any, synchronous_
 
     # Step 3. Add Scan to the system
     payload = {'dataset': dataset_key, 'number_of_slices': 1}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
diff --git a/backend/tests/functional_tests/test_deleting_scan.py b/backend/tests/functional_tests/test_deleting_scan.py
--- a/backend/tests/functional_tests/test_deleting_scan.py
+++ b/backend/tests/functional_tests/test_deleting_scan.py
@@ -32,7 +32,7 @@ def test_delete_scan_without_slices(prepare_environment: Any, synchronous_celery
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 0}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -71,7 +71,7 @@ def test_delete_scan_with_slices(prepare_environment: Any, synchronous_celery: A
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 1}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -132,7 +132,7 @@ def test_delete_scan_with_labels(prepare_environment: Any, synchronous_celery: A
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 1}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
diff --git a/backend/tests/functional_tests/test_scan_upload.py b/backend/tests/functional_tests/test_scan_upload.py
--- a/backend/tests/functional_tests/test_scan_upload.py
+++ b/backend/tests/functional_tests/test_scan_upload.py
@@ -29,7 +29,7 @@ def test_scan_upload_and_conversion(prepare_environment: Any, synchronous_celery
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     json_response = json.loads(response.data)
     scan_id = json_response['scan_id']
@@ -83,7 +83,7 @@ def test_scan_upload_with_retrying(fixture_problems_with_storage: Any, prepare_e
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     json_response = json.loads(response.data)
     scan_id = json_response['scan_id']
diff --git a/backend/tests/functional_tests/test_skipping_a_scan.py b/backend/tests/functional_tests/test_skipping_a_scan.py
--- a/backend/tests/functional_tests/test_skipping_a_scan.py
+++ b/backend/tests/functional_tests/test_skipping_a_scan.py
@@ -18,7 +18,7 @@ def test_skipping_a_scan(prepare_environment: Any, synchronous_celery: Any) -> N
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
diff --git a/backend/tests/functional_tests/test_tools_and_tags.py b/backend/tests/functional_tests/test_tools_and_tags.py
--- a/backend/tests/functional_tests/test_tools_and_tags.py
+++ b/backend/tests/functional_tests/test_tools_and_tags.py
@@ -27,7 +27,7 @@ def test_add_label_non_existing_tag(prepare_environment: Any) -> None:
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -66,7 +66,7 @@ def test_add_label_non_supported_tool(prepare_environment: Any) -> None:
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -106,7 +106,7 @@ def test_add_label_missing_tag(prepare_environment: Any) -> None:
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -145,7 +145,7 @@ def test_add_label_missing_tool(prepare_environment: Any) -> None:
 
     # Step 2. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
@@ -184,7 +184,7 @@ def test_add_label_wrong_tool_for_tag(prepare_environment: Any) -> None:
 
     # Step 1. Add Scan to the system
     payload = {'dataset': 'KIDNEYS', 'number_of_slices': 3}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)
diff --git a/backend/tests/functional_tests/test_users.py b/backend/tests/functional_tests/test_users.py
--- a/backend/tests/functional_tests/test_users.py
+++ b/backend/tests/functional_tests/test_users.py
@@ -82,7 +82,7 @@ def test_upgrade_to_doctor_role(prepare_environment: Any) -> None:
     assert len(admin_user_token) > 100
 
     # Step 2. Admin gets all users
-    response = api_client.get('/api/v1/users/', headers=get_headers(token=admin_user_token))
+    response = api_client.get('/api/v1/users', headers=get_headers(token=admin_user_token))
     assert response.status_code == 200
     json_response = json.loads(response.data)
     assert isinstance(json_response, dict)
@@ -132,7 +132,7 @@ def test_ownership(prepare_environment: Any, synchronous_celery: Any) -> None:
 
     # Step 3. Add Scan to the system
     payload = {'dataset': 'LUNGS', 'number_of_slices': 1}
-    response = api_client.post('/api/v1/scans/', data=json.dumps(payload),
+    response = api_client.post('/api/v1/scans', data=json.dumps(payload),
                                headers=get_headers(token=admin_user_token, json=True))
     assert response.status_code == 201
     json_response = json.loads(response.data)