Merge branch 'tests'
This commit is contained in:
commit
6b837926b2
|
@ -491,8 +491,9 @@ class Schemas(models.Model):
|
|||
try:
|
||||
if is_json:
|
||||
return json.loads(field_value)
|
||||
except json.decoder.JSONDecodeError:
|
||||
return field_value
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return field_value
|
||||
|
||||
def _update_model_field(self, field_attr, field_value):
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import json
|
||||
|
||||
from datetime import datetime
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from django.core.exceptions import FieldError
|
||||
|
@ -15,6 +18,8 @@ class AdminDashboardTableTest(TestCase):
|
|||
self.admin_user = User.objects.create_superuser(
|
||||
email='adminuser@example.org',
|
||||
password='adminpass12')
|
||||
self.admin_user.accept_gdpr=True
|
||||
self.admin_user.save()
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
@ -118,7 +123,18 @@ class TemplateTableTest(TestCase):
|
|||
)
|
||||
|
||||
def format_data_for_json_reader(self, name, description):
|
||||
return '{"name": "'+name+'", "description": "'+description+'"}'
|
||||
v = {
|
||||
"name": [{
|
||||
"lang": settings.LANGUAGE_CODE,
|
||||
"value": name
|
||||
}],
|
||||
"description": [{
|
||||
"lang": settings.LANGUAGE_CODE,
|
||||
"value": description
|
||||
}]
|
||||
}
|
||||
return json.dumps(v)
|
||||
# return '{"name": "'+name+'", "description": "'+description+'"}'
|
||||
|
||||
def test_order_table_by_name_throws_no_exception(self):
|
||||
try:
|
||||
|
|
|
@ -2,6 +2,7 @@ from django.urls import reverse
|
|||
from django.test import Client, TestCase
|
||||
|
||||
from idhub_auth.models import User
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class TemplateTest(TestCase):
|
||||
|
@ -10,6 +11,8 @@ class TemplateTest(TestCase):
|
|||
self.admin_user = User.objects.create_superuser(
|
||||
email='adminuser@example.org',
|
||||
password='adminpass12')
|
||||
self.admin_user.accept_gdpr=True
|
||||
self.admin_user.save()
|
||||
|
||||
def test_dashboard_template(self):
|
||||
self.client.login(email='adminuser@example.org', password='adminpass12')
|
||||
|
|
|
@ -8,11 +8,18 @@ from idhub.admin.views import PeopleListView
|
|||
class AdminDashboardViewTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.user = User.objects.create_user(email='normaluser@example.org',
|
||||
password='testpass12')
|
||||
self.user = User.objects.create_user(
|
||||
email='normaluser@example.org',
|
||||
password='testpass12',
|
||||
)
|
||||
self.user.accept_gdpr=True
|
||||
self.user.save()
|
||||
|
||||
self.admin_user = User.objects.create_superuser(
|
||||
email='adminuser@example.org',
|
||||
password='adminpass12')
|
||||
self.admin_user.accept_gdpr=True
|
||||
self.admin_user.save()
|
||||
|
||||
def test_view_url_exists_at_desired_location(self):
|
||||
response = self.client.get('/admin/dashboard/', follow=True)
|
||||
|
@ -62,14 +69,20 @@ class PeopleListViewTest(TestCase):
|
|||
# Create some user instances for testing
|
||||
self.user = User.objects.create_user(email='normaluser@example.org',
|
||||
password='testpass12')
|
||||
self.user.accept_gdpr=True
|
||||
self.user.save()
|
||||
self.admin_user = User.objects.create_superuser(
|
||||
email='adminuser@example.org',
|
||||
password='adminpass12')
|
||||
self.admin_user.accept_gdpr=True
|
||||
self.admin_user.save()
|
||||
|
||||
# Create a request object for the view
|
||||
self.request = self.factory.get(reverse('idhub:admin_people_list'))
|
||||
|
||||
self.request.user = self.admin_user
|
||||
self.client.login(email='adminuser@example.org', password='adminpass12')
|
||||
self.request.session = self.client.session
|
||||
|
||||
def test_template_used(self):
|
||||
response = PeopleListView.as_view()(self.request)
|
||||
|
|
Loading…
Reference in New Issue