summaryrefslogtreecommitdiff
path: root/yaksh/tests/test_load.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/tests/test_load.py')
-rw-r--r--yaksh/tests/test_load.py56
1 files changed, 6 insertions, 50 deletions
diff --git a/yaksh/tests/test_load.py b/yaksh/tests/test_load.py
index c552137..27ae750 100644
--- a/yaksh/tests/test_load.py
+++ b/yaksh/tests/test_load.py
@@ -14,9 +14,12 @@ from selenium_test import SeleniumTest
from yaksh.code_server import ServerPool, SERVER_POOL_PORT, SERVER_PORTS
from yaksh import settings
from yaksh.xmlrpc_clients import CodeServerProxy
+from django.core.management import call_command
+
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
+
class MySeleniumTests(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
@@ -33,54 +36,7 @@ class MySeleniumTests(StaticLiveServerTestCase):
cls.code_server_thread = t = Thread(target=code_server_pool.run)
t.start()
- # Create set of demo users and profiles
- mod_user = User.objects.create_user(username='yaksh_demo_mod',
- password='yaksh_demo_mod',
- email='yaksh_demo_mod@test.com'
- )
-
- user = User.objects.create_user(username='demo_yaksh_user',
- password='demo_yaksh_user',
- email='demo_yaksh_user@test.com'
- )
- Profile.objects.create(user=user,
- roll_number='demo_rn',
- institute='IIT',
- department='Chemical',
- position='Student'
- )
-
- # create a course
- course = Course.objects.create(name="Demo Load Course",
- enrollment="Open Course",
- creator=mod_user
- )
- course.students.add(user)
-
- # create a Quiz
- quiz = Quiz.objects.create(
- start_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzinfo=pytz.utc),
- end_date_time=datetime(2199, 10, 9, 10, 8, 15, 0, tzinfo=pytz.utc),
- duration=30, active=True,
- attempts_allowed=1, time_between_attempts=0,
- description='yaksh demo quiz', pass_criteria=0,
- language='Python', prerequisite=None,
- course=course
- )
-
- # create a question set
- question = Question()
- with open(os.path.join(CUR_DIR, 'test_questions.json'), 'r') as f:
- question_list = f.read()
- question.load_from_json(question_list, mod_user)
-
- # create question paper
- question_paper = QuestionPaper.objects.create(quiz=quiz,
- total_marks=5,
- shuffle_questions=False
- )
- # add fixed set of questions to the question paper
- question_paper.fixed_questions.add(*Question.objects.all())
+ call_command('create_demo_course')
@classmethod
def tearDownClass(cls):
@@ -96,6 +52,6 @@ class MySeleniumTests(StaticLiveServerTestCase):
def test_load(self):
url = '%s%s' % (self.live_server_url, '/exam/login/')
- quiz_name = "yaksh demo quiz"
+ quiz_name = "Demo_quiz"
selenium_test = SeleniumTest(url=url, quiz_name=quiz_name)
- selenium_test.run_load_test(url=url, username='demo_yaksh_user', password='demo_yaksh_user')
+ selenium_test.run_load_test(url=url, username='demo_student', password='demo_student')