def test_join_class_revoked(self): teacher_email, teacher_password = signup_teacher_directly() create_organisation_directly(teacher_email) klass, class_name, access_code = create_class_directly(teacher_email) create_school_student_directly(access_code) klass.always_accept_requests = True klass.save() homepage = self.go_to_homepage() play_page, student_name, student_username, student_email, password = create_independent_student( homepage ) page = ( play_page.independent_student_login(student_username, password) .go_to_join_a_school_or_club_page() .join_a_school_or_club(access_code) ) assert is_indep_student_join_request_received_message_showing(self.selenium) page.revoke_join_request() assert is_indep_student_join_request_revoked_message_showing(self.selenium)
def test_join_class_revoked(self): teacher_email, _ = signup_teacher_directly() create_organisation_directly(teacher_email) klass, _, access_code = create_class_directly(teacher_email) create_school_student_directly(access_code) klass.always_accept_requests = True klass.save() homepage = self.go_to_homepage() play_page, _, student_username, _, password = create_independent_student( homepage ) page = ( play_page.independent_student_login(student_username, password) .go_to_join_a_school_or_club_page() .join_a_school_or_club(access_code) ) assert is_indep_student_join_request_received_message_showing(self.selenium) page.revoke_join_request() assert is_indep_student_join_request_revoked_message_showing(self.selenium)
def test_join_class_denied(self): teacher_email, teacher_password = signup_teacher_directly() create_organisation_directly(teacher_email) klass, class_name, accesss_code = create_class_directly(teacher_email) create_school_student_directly(accesss_code) klass.always_accept_requests = True klass.save() homepage = self.go_to_homepage() play_page, student_name, student_username, student_email, password = create_independent_student( homepage ) page = ( play_page.independent_student_login(student_username, password) .go_to_join_a_school_or_club_page() .join_a_school_or_club(accesss_code) ) page.logout() page = self.go_to_homepage() dashboard_page = ( page.go_to_login_page() .login(teacher_email, teacher_password) .deny_independent_join_request() ) assert dashboard_page.has_no_independent_join_requests()
def test_join_class_accepted(self): teacher_email, teacher_password = signup_teacher_directly() create_organisation_directly(teacher_email) klass, _, accesss_code = create_class_directly(teacher_email) create_school_student_directly(accesss_code) klass.always_accept_requests = True klass.save() homepage = self.go_to_homepage() ( play_page, student_name, student_username, _, password, ) = create_independent_student(homepage) page = (play_page.independent_student_login( student_username, password).go_to_join_a_school_or_club_page().join_a_school_or_club( accesss_code)) page.logout() page = self.go_to_homepage() page = (page.go_to_login_page().login( teacher_email, teacher_password).accept_independent_join_request().save( student_name).return_to_class()) assert page.student_exists(student_name)
def test_join_class_denied(self): teacher_email, teacher_password = signup_teacher_directly() create_organisation_directly(teacher_email) klass, _, access_code = create_class_directly(teacher_email) create_school_student_directly(access_code) klass.always_accept_requests = True klass.save() homepage = self.go_to_homepage() play_page, _, student_username, _, password = create_independent_student( homepage ) page = ( play_page.independent_student_login(student_username, password) .go_to_join_a_school_or_club_page() .join_a_school_or_club(access_code) ) page.logout() page = self.go_to_homepage() dashboard_page = ( page.go_to_teacher_login_page() .login(teacher_email, teacher_password) .deny_independent_join_request() ) assert dashboard_page.has_no_independent_join_requests()
def set_up_data(classmates_data_viewable=False): email, password = signup_teacher_directly() clas, class_name, access_code = create_class_directly(email) if classmates_data_viewable: clas.classmates_data_viewable = True clas.save() _, _, student = create_school_student_directly(access_code) _, _, student2 = create_school_student_directly(access_code) create_random_school_data() return clas, student, student2
def test_scoreboard_loads(self): email, password = signup_teacher_directly() create_organisation_directly(email) klass, name, access_code = create_class_directly(email) create_school_student_directly(access_code) url = reverse("scoreboard") c = Client() c.login(username=email, password=password) response = c.get(url) self.assertEqual(200, response.status_code)
def login_once(self): if not BaseGameTest.already_logged_on: email, password = signup_teacher_directly() create_organisation_directly(email) klass, name, access_code = create_class_directly(email) create_school_student_directly(access_code) self.go_to_homepage().go_to_login_page().login(email, password) email = email BaseGameTest.user_profile = UserProfile.objects.get(user__email=email) BaseGameTest.already_logged_on = True return BaseGameTest.user_profile
def login_once(self): if not BaseGameTest.already_logged_on: email, password = signup_teacher_directly() create_organisation_directly(email) klass, name, access_code = create_class_directly(email) create_school_student_directly(access_code) self.go_to_homepage().go_to_login_page().login(email, password) email = email BaseGameTest.user_profile = UserProfile.objects.get( user__email=email) BaseGameTest.already_logged_on = True return BaseGameTest.user_profile
def test_join_class_not_accepting_requests(self): teacher_email, teacher_password = signup_teacher_directly() create_organisation_directly(teacher_email) klass, class_name, access_code = create_class_directly(teacher_email) create_school_student_directly(access_code) homepage = self.go_to_homepage() play_page, student_name, student_username, student_email, password = create_independent_student(homepage) page = play_page \ .independent_student_login(student_username, password) \ .go_to_join_a_school_or_club_page() \ .join_a_school_or_club_failure(access_code) assert self.is_join_class_page(page) assert page.has_join_request_failed('Cannot find the school or club and/or class')
def test_anonymous_level_saving_school_student(self): _, email, password = signup_teacher_directly() create_organisation_directly(email) _, class_name, access_code = create_class_directly(email) student_name, student_password, _ = create_school_student_directly( access_code) self.student_login(student_name, access_code, student_password) url = reverse("save_level_for_editor") data1 = { u"origin": u'{"coordinate":[3,5],"direction":"S"}', u"pythonEnabled": False, u"decor": [], u"blocklyEnabled": True, u"blocks": [ { u"type": u"move_forwards" }, { u"type": u"turn_left" }, { u"type": u"turn_right" }, ], u"max_fuel": u"50", u"pythonViewEnabled": False, u"character": u"3", u"name": u"abc", u"theme": 1, u"anonymous": True, u"cows": u"[]", u"path": u'[{"coordinate":[3,5],"connectedNodes":[1]},{"coordinate":[3,4],' u'"connectedNodes":[0]}]', u"traffic_lights": u"[]", u"destinations": u"[[3,4]]", } response = self.client.post(url, {"data": json.dumps(data1)}) assert_that(response.status_code, equal_to(200)) sharing_info1 = json.loads( self.get_sharing_information(json.loads( response.content)["id"]).getvalue()) assert_that(sharing_info1["teacher"]["shared"], equal_to(True)) assert_that(len(mail.outbox), equal_to(0))
def test_moderation_teachers_class(self): email, password = signup_teacher_directly() klass, name, access_code = create_class_directly(email) student_name, _, student = create_school_student_directly(access_code) self.login(email, password) response = self.students_of_class(klass) assert_that(response.status_code, equal_to(200)) assert_that(response.content, equal_to('{"%s": "%s"}' % (student.id, student_name)))
def test_level_saving_school_student(self): _, email, password = signup_teacher_directly() create_organisation_directly(email) _, class_name, access_code = create_class_directly(email) student_name, student_password, _ = create_school_student_directly( access_code) self.student_login(student_name, access_code, student_password) url = reverse('save_level_for_editor') data1 = { u'origin': u'{"coordinate":[3,5],"direction":"S"}', u'pythonEnabled': False, u'decor': [], u'blocklyEnabled': True, u'blocks': [{ u'type': u'move_forwards' }, { u'type': u'turn_left' }, { u'type': u'turn_right' }], u'max_fuel': u'50', u'pythonViewEnabled': False, u'character': u'3', u'name': u'abc', u'theme': 1, u'anonymous': False, u'cows': u'[]', u'path': u'[{"coordinate":[3,5],"connectedNodes":[1]},{"coordinate":[3,4],' u'"connectedNodes":[0]}]', u'traffic_lights': u'[]', u'destinations': u'[[3,4]]' } response = self.client.post(url, {'data': json.dumps(data1)}) assert_that(response.status_code, equal_to(200)) sharing_info1 = json.loads( self.get_sharing_information(json.loads( response.content)['id']).getvalue()) assert_that(sharing_info1['teacher']['shared'], equal_to(True)) assert_that(len(mail.outbox), equal_to(1))
def test_moderation_another_class(self): email, password = signup_teacher_directly() email2, _ = signup_teacher_directly() klass2, _, access_code = create_class_directly(email2) student_name, _, student = create_school_student_directly(access_code) self.login(email, password) response = self.students_of_class(klass2) assert_that(response.status_code, equal_to(404)) assert_that(response.content, empty)
def test_join_class_not_accepting_requests(self): teacher_email, teacher_password = signup_teacher_directly() create_organisation_directly(teacher_email) klass, class_name, access_code = create_class_directly(teacher_email) create_school_student_directly(access_code) homepage = self.go_to_homepage() play_page, student_name, student_username, student_email, password = create_independent_student( homepage ) page = ( play_page.independent_student_login(student_username, password) .go_to_join_a_school_or_club_page() .join_a_school_or_club_failure(access_code) ) assert self.is_join_class_page(page) assert page.has_join_request_failed( "Cannot find the school or club and/or class" )
def student_row(self): email, password = signup_teacher_directly() _, class_name, access_code = create_class_directly(email) _, _, student = create_school_student_directly(access_code) total_time = timedelta(0, 30) scores = [x for x in range(20)] total_score = sum(scores) progress = (0, 0, 0) all_scores = scores + [""] * 89 row = StudentRow(student=student, total_time=total_time, total_score=total_score, start_time=datetime.fromtimestamp(1435305072, tz=utc), finish_time=datetime.fromtimestamp(1438305072, tz=utc), progress=progress, scores=all_scores, class_field=Class(name="MyClass")) return row
def test_level_saving_school_student(self): _, email, password = signup_teacher_directly() create_organisation_directly(email) _, class_name, access_code = create_class_directly(email) student_name, student_password, _ = create_school_student_directly(access_code) self.student_login(student_name, access_code, student_password) url = reverse("save_level_for_editor") data1 = { u"origin": u'{"coordinate":[3,5],"direction":"S"}', u"pythonEnabled": False, u"decor": [], u"blocklyEnabled": True, u"blocks": [ {u"type": u"move_forwards"}, {u"type": u"turn_left"}, {u"type": u"turn_right"}, ], u"max_fuel": u"50", u"pythonViewEnabled": False, u"character": u"3", u"name": u"abc", u"theme": 1, u"anonymous": False, u"cows": u"[]", u"path": u'[{"coordinate":[3,5],"connectedNodes":[1]},{"coordinate":[3,4],' u'"connectedNodes":[0]}]', u"traffic_lights": u"[]", u"destinations": u"[[3,4]]", } response = self.client.post(url, {"data": json.dumps(data1)}) assert_that(response.status_code, equal_to(200)) sharing_info1 = json.loads( self.get_sharing_information(json.loads(response.content)["id"]).getvalue() ) assert_that(sharing_info1["teacher"]["shared"], equal_to(True)) assert_that(len(mail.outbox), equal_to(1))
def create_random_school_data(): email, password = signup_teacher_directly() clas, class_name, access_code = create_class_directly(email) create_school_student_directly(access_code) create_school_student_directly(access_code)