Skip to content

Commit b548d0e

Browse files
HadleyKingReeya123dependabot[bot]
committed
Testing setup (#200)
* 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]>
1 parent 5ee98b4 commit b548d0e

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

.github/workflows/django.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
pip install -r requirements.txt
2727
- name: Run Tests
2828
run: |
29-
cd bco_api;python3.9 manage.py test
29+
python3.9 manage.py test

tests/test_views/test_api_objects_drafts_create.py

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
1-
from django.test import TestCase, Client
2-
from django.contrib.auth.models import User
1+
2+
33
import json
4+
from django.test import TestCase
5+
from django.contrib.auth.models import User
6+
from rest_framework.authtoken.models import Token
7+
from rest_framework.test import APIClient
48

59
class BcoDraftCreateTestCase(TestCase):
6-
def setUp(self):
7-
self.client = Client()
8-
self.url = '/api/objects/drafts/create' # The URL for the create draft endpoint
9-
self.user = User.objects.create_user(username='bco_api_user', password='biocompute')
10+
fixtures = ['tests/fixtures/test_data']
11+
12+
# def setUp(self):
13+
# self.client = Client()
14+
# self.url = '/api/objects/drafts/create' # The URL for the create draft endpoint
15+
# self.user = User.objects.create_user(username='bco_api_user', password='biocompute')
1016

1117
def test_successful_creation(self):
12-
# force logging
13-
self.client.force_login(self.user)
18+
"""200: Creation of BCO draft is successful.
19+
"""
20+
21+
client = APIClient()
22+
token = Token.objects.get(user=User.objects.get(username='bco_api_user')).key
23+
client.credentials(HTTP_AUTHORIZATION='Token ' + token)
1424

15-
# Test case for successful creation (response code 200)
1625
data = {
17-
'prefix': 'string',
18-
'owner_group': 'string',
19-
'object_id': 'string',
20-
'schema': 'string',
21-
'contents': {
22-
"additionalProp1": {}
23-
}
26+
'POST_api_objects_draft_create': [
27+
{
28+
'prefix': 'BCO',
29+
'owner_group': 'bco_drafter',
30+
'schema': 'IEEE',
31+
'contents': {}
32+
},
33+
{
34+
'prefix': 'Hadley',
35+
'owner_group': 'bco_drafter',
36+
'schema': 'IEEE',
37+
'contents': {}
38+
}
39+
]
2440
}
25-
response = self.client.post(self.url, data=json.dumps(data), content_type='application/json', follow=True)
41+
response = client.post('/api/objects/drafts/create/',data, format='json')
42+
import pdb; pdb.set_trace()
2643
self.assertEqual(response.status_code, 200)
27-
# Checking the response. I believe it's JSON)
28-
response_data = json.loads(response.content)
2944

3045
def test_partial_failure(self):
3146
# Test case for partial failure (response code 300)

0 commit comments

Comments
 (0)