Skip to content

Commit 108b983

Browse files
committed
Merge branch 'testing' into 22.04
2 parents 556f15f + b3f8419 commit 108b983

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

bco_api/api/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class bco(models.Model):
7777

7878
def __str__(self):
7979
"""String for representing the BCO model (in Admin site etc.)."""
80-
return self.object_id
80+
return str(self.object_id)
8181

8282

8383
# Generic meta data model

bco_api/api/tests/__init__.py

Whitespace-only changes.

bco_api/api/tests/test_forms.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python3
2+
"""Forms Testing
3+
4+
"""
5+
6+
from django.test import TestCase
7+
8+
# Create your tests here.

bco_api/api/tests/test_models.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
"""Models Testing
3+
4+
"""
5+
6+
from django.test import TestCase
7+
from api.models import bco
8+
from django.utils import timezone
9+
from django.contrib.auth.models import Group, Permission, User
10+
from api.scripts.method_specific.POST_api_objects_drafts_create import POST_api_objects_drafts_create
11+
from django.urls import reverse
12+
13+
class BcoTestCase(TestCase):
14+
"""Test for BCO"""
15+
16+
def create_bco(self):
17+
"""Create Test BCO
18+
19+
"""
20+
21+
return bco.objects.create(
22+
contents={"object_id":"https://localhost:8080/TEST_000000/1.0"},
23+
object_class=None,
24+
object_id='http://localhost:8000/TEST_000000/1.0',
25+
owner_user=User.objects.get(username='anon'),
26+
owner_group=Group.objects.get(name='bco_drafter'),
27+
prefix='TEST',
28+
schema='IEEE',
29+
state='PUBLISHED',
30+
last_update=timezone.now()
31+
)
32+
33+
def test_bco_creation(self):
34+
"""test BCO creation
35+
"""
36+
37+
biocompute = self.create_bco()
38+
self.assertTrue(isinstance(biocompute, bco))
39+
self.assertEqual(biocompute.__str__(), biocompute.object_id)
40+
41+
def test_bco_view(self):
42+
"""Test BCO Draft submission
43+
"""
44+
object_id_root = 'TEST_000000'
45+
url = reverse('api:TEST_000000')
46+
resp = self.client.get(url)
47+
print(resp)
48+
self.assertEqual(resp.status_code, 200)

bco_api/api/tests/test_views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python3
2+
"""Views Testing
3+
4+
"""
5+
6+
from django.test import TestCase

0 commit comments

Comments
 (0)