Example #1
0
 def test_find_student(self, setupGstudent):
     actor = mockInteractor()
     gstudent = Gstudents('test_url', actor)
     actor._test_set_records([{
         'student_id': 'B1',
         'name': 'john'
     }, {
         'student_id': 'B2',
         'name': 'Ann'
     }])
     stu = gstudent.get_student('B1')
     assert ({'student_id': 'B1', 'name': 'john'} == stu)
Example #2
0
 def test_raise_runtime_err_when_finding_multiple_student_with_same_id(
         self):
     actor = mockInteractor()
     gstudent = Gstudents('test_url', actor)
     actor._test_set_records([{
         'student_id': 'B1',
         'name': 'john'
     }, {
         'student_id': 'B1',
         'name': 'Ann'
     }])
     with pytest.raises(RuntimeError,
                        match=r"duplicate student_id :.*") as excinfo:
         gstudent.get_student('B1')
 def test_error_on_duplicate_id(self):
     actor = mockInteractor()
     actor._test_set_records(
         [
             {
                 "student_id": "A1",
                 "github_handle": "aaa",
                 "name": "Andy",
                 "email": "*****@*****.**",
             },
             {
                 "student_id": "A1",
                 "github_handle": "bbb",
                 "name": "Ben",
                 "email": "*****@*****.**",
             },
             {
                 "student_id": "A3",
                 "github_handle": "ccc",
                 "name": "Cindy",
                 "email": "*****@*****.**",
             },
         ],
         title="StudentInfo",
     )
     with pytest.raises(ERR_UNIQUE_STUDENT_ID):
         Gstudents("test_url", actor)
 def test_error_on_spacy_config_fields(self):
     actor = mockInteractor()
     actor._test_set_records(
         [
             {
                 "student_id": " A1",
                 "github_handle": "aa a",
                 "name": "Andy",
                 "email": "*****@*****.**",
             },
         ],
         title="StudentInfo",
     )
     with pytest.raises(ERR_REQUIRE_NO_SPACE):
         Gstudents("test_url", actor)
Example #5
0
 def test_init_must_call_open_by_url(self):
     actor = mockInteractor()
     gstudents = Gstudents('test_url', actor)
     assert (actor.open_by_url_called == True)
Example #6
0
def setupGstudent():
    return Gstudents('test_url', mockInteractor())
def gstudent():
    return Gstudents("test_url", mockInteractor())