Example #1
0
    def test_basic(self):
        fill_db()
        url = reverse("EEG.API.views.course_list")
        resp = self.client.get(url)

        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.content, "software_management,bic_capstone")
Example #2
0
    def test_smoke(self):
        fill_db()
        url = reverse("EEG.prof.views.profhome")
        self.client.login(username='******', password='******')
        resp = self.client.get(url)

        self.assertRedirects(resp, '/EEG/course/software_management')
Example #3
0
 def test_basic(self):
     fill_db()
     url = reverse("EEG.API.views.get_next_lecture",
                   args=['software_management'])
     resp = self.client.get(url)
     self.assertEqual(resp.status_code, 200)
     self.assertGreater(len(resp.content), 10)  # TODO: properly check date
Example #4
0
 def test_direct_input(self):
     fill_db()
     sequences = get_label_sequence("software_management",
                                    "lecture 1",
                                    ["confusion"],
                                    [(1, 2), (2, 3), (11, 12)])
     confusions = sequences["confusion"]
     self.assertEqual(confusions, [(0, 0), (1, 0), (2, 1)])
Example #5
0
 def test_good_input(self):
     fill_db()
     url = reverse("EEG.prof.views.add_course")
     self.client.login(username='******', password='******')
     resp = self.client.post(url, {
         'content_group_name': 'rocket_science',
         'students': ''
     })
     self.assertRedirects(resp, '/EEG/add_lecture/rocket_science')
Example #6
0
    def test_get_form(self):
        fill_db()
        url = reverse("EEG.prof.views.add_course")
        self.client.login(username='******', password='******')
        resp = self.client.get(url, {'lecture': 'lecture 2'})

        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.context['lectureall']), 0)
        self.assertEqual(resp.context['courseall'][0].name,
                         'software_management')
        self.assertEqual(resp.context['courseall'][1].name, 'bic_capstone')
        self.assertEqual(len(resp.context['courseall']), 2)
Example #7
0
 def test_basic(self):
     fill_db()
     url = reverse("EEG.API.views.get_label_sequence")
     resp = self.client.get(
         url, {
             "content_group_name": "software_management",
             "content_name": "lecture 1",
             "label_type_names": '["confusion"]',
             "subsections": "[[0, 1], [1, 2], [11, 12]]"
         })
     self.assertEqual(resp.status_code, 200)
     obj = json.loads(resp.content)
     self.assertEqual(obj['confusion'], [[0, 0], [1, 0], [2, 1]])
Example #8
0
    def test_good_input(self):
        fill_db()
        url = reverse("EEG.student.views.start_session")
        resp = self.client.post(
            url, {
                "content_group_name": "software_management",
                "content_name": "lecture 1",
                "content_time": 0.0,
                "viewer_name": '["alice"]'
            })

        obj = json.loads(resp.content)
        self.assertEqual(obj['ok'], True)
        self.assertEqual(obj['session_name'], "session 1")
Example #9
0
    def test_without_lecture(self):
        fill_db()
        url = reverse("EEG.prof.views.course", args=['software_management'])
        self.client.login(username='******', password='******')
        resp = self.client.get(url)

        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['current_lecture'].name, 'lecture 1')
        self.assertEqual(resp.context['lectureall'][0].name, 'lecture 1')
        self.assertEqual(resp.context['lectureall'][1].name, 'lecture 2')
        self.assertEqual(len(resp.context['lectureall']), 2)
        self.assertEqual(resp.context['courseall'][0].name,
                         'software_management')
        self.assertEqual(resp.context['courseall'][1].name, 'bic_capstone')
        self.assertEqual(len(resp.context['courseall']), 2)
        self.assertEqual(resp.context['current_course'].name,
                         'software_management')
Example #10
0
    def test_good_input(self):
        fill_db()
        url = reverse("EEG.prof.views.add_video_lecture",
                      args=['software_management'])
        self.client.login(username='******', password='******')
        video_url = 'https://www.youtube.com/watch?v=ACjLuMvbAnM'
        resp = self.client.post(url, {'name': 'lecture 0', 'url': video_url})

        expected_start = 'http://testserver/EEG/course/software_management?'
        self.assertEqual(resp['location'][:len(expected_start)],
                         expected_start)

        # check whether lecture was added
        resp2 = self.client.get(resp['location'])
        self.assertEqual(len(resp2.context['lectureall']), 3)
        self.assertEqual(resp2.context['current_lecture'].name, 'lecture 0')
        self.assertEqual(len(VideoContent.objects.filter(video_url=video_url)),
                         1)
Example #11
0
    def test_good_input(self):
        fill_db()
        url = reverse("EEG.prof.views.add_lecture",
                      args=['software_management'])
        self.client.login(username='******', password='******')
        resp = self.client.post(
            url, {
                'name': 'lecture 0',
                'start_date': '2020-01-01 00:00:00',
                'end_date': '2020-01-01 01:00:00'
            })

        expected_start = 'http://testserver/EEG/course/software_management?'
        self.assertEqual(resp['location'][:len(expected_start)],
                         expected_start)

        # check whether lecture was added
        resp2 = self.client.get(resp['location'])
        self.assertEqual(len(resp2.context['lectureall']), 3)
        self.assertEqual(resp2.context['current_lecture'].name, 'lecture 0')
Example #12
0
    def test_basic(self):
        fill_db()
        url = reverse("EEG.API.views.input")

        # TODO: figure out time zone of source
        # confusionTask
        resp = self.client.post(
            url, {
                'course': 'software_management',
                'student': 'alice',
                'label_names': '["confusion"]',
                'label_values': '[1]',
                'start_time': '2018-01-01 06:00:00',
                'end_time': '2018-01-01 06:00:10'
            })
        self.assertEqual(resp.status_code, 200)
        course = ContentGroup.objects.filter(name='software_management').get()
        lecture = Session.objects.filter(content__name='lecture 2',
                                         content__group=course).get()
        confs = Label.objects.filter(tag__start_time__lte=lecture.end_time,
                                     tag__end_time__gt=lecture.start_time,
                                     label_type__name="confusion")
        self.assertEqual(len(confs), 1)
        self.assertEqual(confs[0].true, 1)
        self.assertEqual(confs[0].tag.subject.user.username, 'alice')

        # raw/attention
        resp = self.client.post(
            url, {
                'course': 'software_management',
                'student': 'alice',
                'attention': 1,
                'raw': '1 2 3 4 5',
                'start_time': '2018-01-01 06:00:00',
                'end_time': '2018-01-01 06:00:10'
            })
        self.assertEqual(resp.status_code, 200)
        raws = Raw.objects.filter(start_time__lte=lecture.end_time,
                                  end_time__gt=lecture.start_time)
        self.assertEqual(len(raws), 1)
        self.assertEqual(raws[0].rawwave, '1 2 3 4 5')
Example #13
0
    def test_good_input(self):
        fill_db()
        # first start a session
        url = reverse("EEG.student.views.start_session")
        resp = self.client.post(
            url, {
                "content_group_name": "software_management",
                "content_name": "lecture 1",
                "content_time": 0.0,
                "viewer_name": '["alice"]'
            })
        obj = json.loads(resp.content)
        session_name = obj['session_name']
        self.assertEqual(session_name, 'session 1')

        # now stop the session
        url = reverse("EEG.student.views.stop_session")
        resp = self.client.post(
            url, {
                "content_group_name": "software_management",
                "content_name": "lecture 1",
                "session_name": session_name,
                "content_time": 0.0,
                "viewer_name": '["alice"]'
            })
        obj = json.loads(resp.content)
        self.assertEqual(obj['ok'], True)
        # TODO: test end_time

        # start another one
        url = reverse("EEG.student.views.start_session")
        resp = self.client.post(
            url, {
                "content_group_name": "software_management",
                "content_name": "lecture 1",
                "content_time": 0.0,
                "viewer_name": '["alice"]'
            })
        obj = json.loads(resp.content)
        session_name = obj['session_name']
        self.assertEqual(session_name, 'session 2')
Example #14
0
    def test_direct_input(self):
        fill_db()
        url = reverse("EEG.debug.views.directInput")
        resp = self.client.get(url, {'student': 'alice', 'confusion': 1})

        self.assertEqual(resp.status_code, 200)