Skip to content

Commit

Permalink
Merge branch 'testing' into 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
HadleyKing committed Apr 1, 2022
2 parents 556f15f + b3f8419 commit 108b983
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bco_api/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class bco(models.Model):

def __str__(self):
"""String for representing the BCO model (in Admin site etc.)."""
return self.object_id
return str(self.object_id)


# Generic meta data model
Expand Down
Empty file added bco_api/api/tests/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions bco_api/api/tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
"""Forms Testing
"""

from django.test import TestCase

# Create your tests here.
48 changes: 48 additions & 0 deletions bco_api/api/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""Models Testing
"""

from django.test import TestCase
from api.models import bco
from django.utils import timezone
from django.contrib.auth.models import Group, Permission, User
from api.scripts.method_specific.POST_api_objects_drafts_create import POST_api_objects_drafts_create
from django.urls import reverse

class BcoTestCase(TestCase):
"""Test for BCO"""

def create_bco(self):
"""Create Test BCO
"""

return bco.objects.create(
contents={"object_id":"https://localhost:8080/TEST_000000/1.0"},
object_class=None,
object_id='http://localhost:8000/TEST_000000/1.0',
owner_user=User.objects.get(username='anon'),
owner_group=Group.objects.get(name='bco_drafter'),
prefix='TEST',
schema='IEEE',
state='PUBLISHED',
last_update=timezone.now()
)

def test_bco_creation(self):
"""test BCO creation
"""

biocompute = self.create_bco()
self.assertTrue(isinstance(biocompute, bco))
self.assertEqual(biocompute.__str__(), biocompute.object_id)

def test_bco_view(self):
"""Test BCO Draft submission
"""
object_id_root = 'TEST_000000'
url = reverse('api:TEST_000000')
resp = self.client.get(url)
print(resp)
self.assertEqual(resp.status_code, 200)
6 changes: 6 additions & 0 deletions bco_api/api/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python3
"""Views Testing
"""

from django.test import TestCase

0 comments on commit 108b983

Please sign in to comment.