kopia lustrzana https://github.com/OpenDroneMap/WebODM
Moved test files into tests/ folder
rodzic
6591a25a78
commit
c2e35d30d4
|
@ -0,0 +1,48 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
from django.contrib.auth.models import User, Group
|
||||||
|
from app.models import Project
|
||||||
|
from app.boot import boot
|
||||||
|
|
||||||
|
class BootTestCase(TestCase):
|
||||||
|
'''
|
||||||
|
This class provides optional default mock data as well as
|
||||||
|
proper boot initialization code. All tests for the app
|
||||||
|
module should derive from this class instead of TestCase.
|
||||||
|
|
||||||
|
We don't use fixtures because we have signal initialization login
|
||||||
|
for some models, which doesn't play well with them, and this: http://blog.namis.me/2012/04/21/burn-your-fixtures/
|
||||||
|
'''
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
def setupUsers():
|
||||||
|
User.objects.create_superuser(username='testsuperuser',
|
||||||
|
email='superuser@test.com',
|
||||||
|
password='test1234')
|
||||||
|
User.objects.create_user(username='testuser',
|
||||||
|
email='user@test.com',
|
||||||
|
password='test1234')
|
||||||
|
User.objects.create_user(username='testuser2',
|
||||||
|
email='user2@test.com',
|
||||||
|
password='test1234')
|
||||||
|
|
||||||
|
def setupProjects():
|
||||||
|
Project.objects.create(
|
||||||
|
owner=User.objects.get(username="testsuperuser"),
|
||||||
|
name="Super User Test Project",
|
||||||
|
description="This is a test project"
|
||||||
|
)
|
||||||
|
Project.objects.create(
|
||||||
|
owner=User.objects.get(username="testuser"),
|
||||||
|
name="User Test Project",
|
||||||
|
description="This is a test project"
|
||||||
|
)
|
||||||
|
Project.objects.create(
|
||||||
|
owner=User.objects.get(username="testuser2"),
|
||||||
|
name="User 2 Test Project",
|
||||||
|
description="This is a test project"
|
||||||
|
)
|
||||||
|
|
||||||
|
super(BootTestCase, cls).setUpClass()
|
||||||
|
boot()
|
||||||
|
setupUsers()
|
||||||
|
setupProjects()
|
|
@ -1,4 +1,4 @@
|
||||||
from app.tests import BootTestCase
|
from .classes import BootTestCase
|
||||||
from rest_framework.test import APIClient
|
from rest_framework.test import APIClient
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
|
|
|
@ -1,61 +1,11 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.test import Client
|
from django.test import Client
|
||||||
|
|
||||||
from .models import Project, Task
|
from app.models import Project, Task
|
||||||
from .boot import boot
|
from .classes import BootTestCase
|
||||||
|
|
||||||
import api.tests
|
|
||||||
|
|
||||||
class BootTestCase(TestCase):
|
|
||||||
'''
|
|
||||||
This class provides optional default mock data as well as
|
|
||||||
proper boot initialization code. All tests for the app
|
|
||||||
module should derive from this class instead of TestCase.
|
|
||||||
|
|
||||||
We don't use fixtures because we have signal initialization login
|
|
||||||
for some models, which doesn't play well with them, and this: http://blog.namis.me/2012/04/21/burn-your-fixtures/
|
|
||||||
'''
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
def setupUsers():
|
|
||||||
User.objects.create_superuser(username='testsuperuser',
|
|
||||||
email='superuser@test.com',
|
|
||||||
password='test1234')
|
|
||||||
User.objects.create_user(username='testuser',
|
|
||||||
email='user@test.com',
|
|
||||||
password='test1234')
|
|
||||||
User.objects.create_user(username='testuser2',
|
|
||||||
email='user2@test.com',
|
|
||||||
password='test1234')
|
|
||||||
|
|
||||||
def setupProjects():
|
|
||||||
Project.objects.create(
|
|
||||||
owner=User.objects.get(username="testsuperuser"),
|
|
||||||
name="Super User Test Project",
|
|
||||||
description="This is a test project"
|
|
||||||
)
|
|
||||||
Project.objects.create(
|
|
||||||
owner=User.objects.get(username="testuser"),
|
|
||||||
name="User Test Project",
|
|
||||||
description="This is a test project"
|
|
||||||
)
|
|
||||||
Project.objects.create(
|
|
||||||
owner=User.objects.get(username="testuser2"),
|
|
||||||
name="User 2 Test Project",
|
|
||||||
description="This is a test project"
|
|
||||||
)
|
|
||||||
|
|
||||||
super(BootTestCase, cls).setUpClass()
|
|
||||||
boot()
|
|
||||||
setupUsers()
|
|
||||||
setupProjects()
|
|
||||||
|
|
||||||
|
|
||||||
class TestApp(BootTestCase):
|
class TestApp(BootTestCase):
|
||||||
|
|
||||||
fixtures = ['test_processingnodes', ]
|
fixtures = ['test_processingnodes', ]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
Ładowanie…
Reference in New Issue