Skip to content

Commit

Permalink
Testing setup (#200)
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]>

---------

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 5ee98b4 commit 65591f7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
pip install -r requirements.txt
- name: Run Tests
run: |
cd bco_api;python3.9 manage.py test
python3.9 manage.py test
53 changes: 34 additions & 19 deletions tests/test_views/test_api_objects_drafts_create.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
from django.test import TestCase, Client
from django.contrib.auth.models import User


import json
from django.test import TestCase
from django.contrib.auth.models import User
from rest_framework.authtoken.models import Token
from rest_framework.test import APIClient

class BcoDraftCreateTestCase(TestCase):
def setUp(self):
self.client = Client()
self.url = '/api/objects/drafts/create' # The URL for the create draft endpoint
self.user = User.objects.create_user(username='bco_api_user', password='biocompute')
fixtures = ['tests/fixtures/test_data']

# def setUp(self):
# self.client = Client()
# self.url = '/api/objects/drafts/create' # The URL for the create draft endpoint
# self.user = User.objects.create_user(username='bco_api_user', password='biocompute')

def test_successful_creation(self):
# force logging
self.client.force_login(self.user)
"""200: Creation of BCO draft is successful.
"""

client = APIClient()
token = Token.objects.get(user=User.objects.get(username='bco_api_user')).key
client.credentials(HTTP_AUTHORIZATION='Token ' + token)

# Test case for successful creation (response code 200)
data = {
'prefix': 'string',
'owner_group': 'string',
'object_id': 'string',
'schema': 'string',
'contents': {
"additionalProp1": {}
}
'POST_api_objects_draft_create': [
{
'prefix': 'BCO',
'owner_group': 'bco_drafter',
'schema': 'IEEE',
'contents': {}
},
{
'prefix': 'Hadley',
'owner_group': 'bco_drafter',
'schema': 'IEEE',
'contents': {}
}
]
}
response = self.client.post(self.url, data=json.dumps(data), content_type='application/json', follow=True)
response = client.post('/api/objects/drafts/create/',data, format='json')
import pdb; pdb.set_trace()
self.assertEqual(response.status_code, 200)
# Checking the response. I believe it's JSON)
response_data = json.loads(response.content)

def test_partial_failure(self):
# Test case for partial failure (response code 300)
Expand Down

0 comments on commit 65591f7

Please sign in to comment.