Skip to content

Commit

Permalink
Get published object by (#201)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
4 people authored Jul 27, 2023
1 parent 65591f7 commit f2743d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
4 changes: 2 additions & 2 deletions api/scripts/method_specific/GET_published_object_by_id.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The BCO model
from ...models import BCO
from api.models import BCO

# Responses
from rest_framework import status
Expand Down Expand Up @@ -107,5 +107,5 @@ def GET_published_object_by_id(oi_root):
print("No objects were found for the root ID provided.")
return Response(
data="No objects were found for the root ID provided.",
status=status.HTTP_400_BAD_REQUEST,
status=status.HTTP_404_NOT_FOUND,
)
18 changes: 3 additions & 15 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,19 +1669,10 @@ def get(self, request, object_id):
class ObjectIdRootObjectId(APIView):
"""
View Published BCO by ID
--------------------
Reads and returns a published BCO based on an object ID.
Reads and returns a published BCO based on an object ID. This will return the highest versioned object.
"""

# For the success and error messages
# renderer_classes = [
# TemplateHTMLRenderer
# ]
# template_name = 'api/account_activation_message.html'

auth = []
auth.append(
openapi.Parameter(
Expand All @@ -1692,17 +1683,14 @@ class ObjectIdRootObjectId(APIView):
)
)

# Anyone can view a published object
authentication_classes = []
permission_classes = []

@swagger_auto_schema(
manual_parameters=auth,
responses={
201: "Account has been authorized.",
208: "Account has already been authorized.",
403: "Requestor's credentials were rejected.",
424: "Account has not been registered.",
200: "Object returned.",
404: "Object not found."
},
tags=["BCO Management"],
)
Expand Down
26 changes: 26 additions & 0 deletions tests/test_views/test_published_object_by_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

"""Root Object Id Testing
Tests for 'Object Found' (200) and 'Object Not Found'(404)
"""

from django.test import TestCase
from rest_framework.test import APIClient

class ObjectIdRootObjectIdTest(TestCase):
fixtures = ['tests/fixtures/test_data']

def test_seccussfull_retrieval(self):
"""200: Object returned.
"""

client = APIClient()
response = self.client.get('/BCO_000001')
self.assertEqual(response.status_code, 200)

def test_object_not_found(self):
"""404: Object not found.
"""

response = self.client.get('/BCO_001000')
self.assertEqual(response.status_code, 404)

0 comments on commit f2743d2

Please sign in to comment.