Skip to content

Commit ab0044d

Browse files
HadleyKingReeya123dependabot[bot]
committed
Get published object by (#201)
* unit tests test_fixtures.py - Exports the database as a pytest fixture that can be used for testing * Add files via upload * New api test files * Fixed test_api_accounts_describe Changes to be committed: modified: api/apps.py modified: api/model/groups.py modified: api/model/prefix.py deleted: api/tests/test_bcos.json deleted: api/tests/test_forms.py deleted: api/tests/test_group_post_api.py deleted: api/tests/test_model_bco.py deleted: api/tests/test_model_groups.py deleted: api/tests/test_model_prefix.py deleted: api/tests/test_model_user.py deleted: api/tests/test_prefix_post_api.py deleted: api/tests/test_views.py deleted: api/tests_automated.py modified: api/views.py modified: bcodb/settings.py renamed: api/tests/__init__.py -> tests/__init__.py new file: tests/fixtures/test_data.json modified: tests/test_fixtures.py new file: tests/test_views/__init__.py modified: tests/test_views/test_api_accounts_describe.py * Fix Bulk Publish function Changes to be committed: modified: api/scripts/method_specific/POST_api_objects_publish.py modified: api/scripts/utilities/JsonUtils.py * Add reset_token API Issue #158 * Formatting for Add/Remove ORCID updated dev DB Related to biocompute-objects/portal_userdb#90 Changes to be committed: modified: admin_only/db.sqlite3.dev modified: authentication/apis.py * Fix #134 Changes to be committed: modified: authentication/services.py * Bump django from 3.2.10 to 3.2.13 Bumps [django](https://github.com/django/django) from 3.2.10 to 3.2.13. - [Release notes](https://github.com/django/django/releases) - [Commits](django/django@3.2.10...3.2.13) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * new test - auth/remove * conflicts solved and merged * new bracnh for conflict resolution Changes to be committed: modified: .github/workflows/django.yml modified: tests/test_views/test_api_objects_drafts_create.py * update (#198) * Fix Bulk Publish function Changes to be committed: modified: api/scripts/method_specific/POST_api_objects_publish.py modified: api/scripts/utilities/JsonUtils.py * Add reset_token API Issue #158 * Formatting for Add/Remove ORCID updated dev DB Related to biocompute-objects/portal_userdb#90 Changes to be committed: modified: admin_only/db.sqlite3.dev modified: authentication/apis.py * Fix #134 Changes to be committed: modified: authentication/services.py * Bump django from 3.2.10 to 3.2.13 Bumps [django](https://github.com/django/django) from 3.2.10 to 3.2.13. - [Release notes](https://github.com/django/django/releases) - [Commits](django/django@3.2.10...3.2.13) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * added new test file- api/auth/remove.py (#196) * unit tests test_fixtures.py - Exports the database as a pytest fixture that can be used for testing * Add files via upload * New api test files * Fixed test_api_accounts_describe Changes to be committed: modified: api/apps.py modified: api/model/groups.py modified: api/model/prefix.py deleted: api/tests/test_bcos.json deleted: api/tests/test_forms.py deleted: api/tests/test_group_post_api.py deleted: api/tests/test_model_bco.py deleted: api/tests/test_model_groups.py deleted: api/tests/test_model_prefix.py deleted: api/tests/test_model_user.py deleted: api/tests/test_prefix_post_api.py deleted: api/tests/test_views.py deleted: api/tests_automated.py modified: api/views.py modified: bcodb/settings.py renamed: api/tests/__init__.py -> tests/__init__.py new file: tests/fixtures/test_data.json modified: tests/test_fixtures.py new file: tests/test_views/__init__.py modified: tests/test_views/test_api_accounts_describe.py * Fix Bulk Publish function Changes to be committed: modified: api/scripts/method_specific/POST_api_objects_publish.py modified: api/scripts/utilities/JsonUtils.py * Add reset_token API Issue #158 * Formatting for Add/Remove ORCID updated dev DB Related to biocompute-objects/portal_userdb#90 Changes to be committed: modified: admin_only/db.sqlite3.dev modified: authentication/apis.py * Fix #134 Changes to be committed: modified: authentication/services.py * Bump django from 3.2.10 to 3.2.13 Bumps [django](https://github.com/django/django) from 3.2.10 to 3.2.13. - [Release notes](https://github.com/django/django/releases) - [Commits](django/django@3.2.10...3.2.13) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * new test - auth/remove * conflicts solved and merged --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Hadley King <[email protected]> Co-authored-by: hadleyking <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Reeya Gupta <[email protected]> * Fix Swagger for `GET_published_object_by_id` * tests and documentation for 'get_object_id' Fix #178 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Reeya Gupta <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Reeya Gupta <[email protected]>
1 parent b548d0e commit ab0044d

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

api/scripts/method_specific/GET_published_object_by_id.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The BCO model
2-
from ...models import BCO
2+
from api.models import BCO
33

44
# Responses
55
from rest_framework import status
@@ -107,5 +107,5 @@ def GET_published_object_by_id(oi_root):
107107
print("No objects were found for the root ID provided.")
108108
return Response(
109109
data="No objects were found for the root ID provided.",
110-
status=status.HTTP_400_BAD_REQUEST,
110+
status=status.HTTP_404_NOT_FOUND,
111111
)

api/views.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,19 +1669,10 @@ def get(self, request, object_id):
16691669
class ObjectIdRootObjectId(APIView):
16701670
"""
16711671
View Published BCO by ID
1672-
16731672
--------------------
1674-
1675-
Reads and returns a published BCO based on an object ID.
1676-
1673+
Reads and returns a published BCO based on an object ID. This will return the highest versioned object.
16771674
"""
16781675

1679-
# For the success and error messages
1680-
# renderer_classes = [
1681-
# TemplateHTMLRenderer
1682-
# ]
1683-
# template_name = 'api/account_activation_message.html'
1684-
16851676
auth = []
16861677
auth.append(
16871678
openapi.Parameter(
@@ -1692,17 +1683,14 @@ class ObjectIdRootObjectId(APIView):
16921683
)
16931684
)
16941685

1695-
# Anyone can view a published object
16961686
authentication_classes = []
16971687
permission_classes = []
16981688

16991689
@swagger_auto_schema(
17001690
manual_parameters=auth,
17011691
responses={
1702-
201: "Account has been authorized.",
1703-
208: "Account has already been authorized.",
1704-
403: "Requestor's credentials were rejected.",
1705-
424: "Account has not been registered.",
1692+
200: "Object returned.",
1693+
404: "Object not found."
17061694
},
17071695
tags=["BCO Management"],
17081696
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
3+
"""Root Object Id Testing
4+
Tests for 'Object Found' (200) and 'Object Not Found'(404)
5+
"""
6+
7+
from django.test import TestCase
8+
from rest_framework.test import APIClient
9+
10+
class ObjectIdRootObjectIdTest(TestCase):
11+
fixtures = ['tests/fixtures/test_data']
12+
13+
def test_seccussfull_retrieval(self):
14+
"""200: Object returned.
15+
"""
16+
17+
client = APIClient()
18+
response = self.client.get('/BCO_000001')
19+
self.assertEqual(response.status_code, 200)
20+
21+
def test_object_not_found(self):
22+
"""404: Object not found.
23+
"""
24+
25+
response = self.client.get('/BCO_001000')
26+
self.assertEqual(response.status_code, 404)

0 commit comments

Comments
 (0)