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, _, 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 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)
Exemplo n.º 6
0
    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))
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
    def login_once(self):
        if not BaseGameTest.already_logged_on:
            email, password = signup_teacher_directly()
            create_organisation_directly(email)
            self.go_to_homepage().go_to_teach_page().login(email, password)
            email = email
            BaseGameTest.user_profile = UserProfile.objects.get(user__email=email)

            BaseGameTest.already_logged_on = True

        return BaseGameTest.user_profile
Exemplo n.º 9
0
    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))
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
    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
Exemplo n.º 12
0
    def test_populating_valid_postcodes(self, mock_lookup_country):
        # Setting up mock
        values = {
            (u'AL10 9NE'): (None, 'GB', 'Hatfield', 51.7623259, -0.2438929),
            (u'SW7 2AZ'): (None, 'GB', 'London', 51.5005046999999, -0.1782187),
            (u'CR3 7YA'): (None, 'GB', 'Caterham', 51.2763229, -0.051738),
            (u'10000'):
            (None, 'MX', 'Leon de los Aldama', 21.0859338, -101.5219684),
            (u'230-890'):
            (None, 'KR', 'Yeongwol-gun', 37.2382906, 128.5322833),
            (u'9446 PA'): (None, 'NL', 'Amen', 52.94067159999999, 6.6120059),
        }

        def side_effect(args):
            return values[args]

        mock_lookup_country.side_effect = side_effect

        # Creating Data
        email_address, password = signup_teacher_directly()

        organisations = []
        # Real postcodes from different countries
        organisations.append(
            create_organisation_directly(email_address, postcode='SW7 2AZ'))
        organisations.append(
            create_organisation_directly(email_address, postcode='CR3 7YA'))
        organisations.append(
            create_organisation_directly(email_address, postcode='10000'))
        organisations.append(
            create_organisation_directly(email_address, postcode='230-890'))
        organisations.append(
            create_organisation_directly(email_address, postcode='9446 PA'))

        # Migrating
        self.migrate_to_dest()

        # Assertion: check that all the country fields are populated
        countries = {
            (u'AL10 9NE'): ('GB'),
            (u'SW7 2AZ'): ('GB'),
            (u'CR3 7YA'): ('GB'),
            (u'10000'): ('MX'),
            (u'230-890'): ('KR'),
            (u'9446 PA'): ('NL'),
        }
        for organisation in organisations:
            school = School.objects.get(name=organisation[0])
            self.assertTrue(school.country, countries[school.postcode])
    def test_join_class(self):
        teacher_email, teacher_password = signup_teacher_directly()
        organisation_name, postcode = create_organisation_directly(teacher_email)
        klass, class_name, accesss_code = create_class_directly(teacher_email)
        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)

        logged_out_homepage = page.logout()

        classes_page = logged_out_homepage \
            .go_to_teach_page() \
            .login(teacher_email, teacher_password) \
            .go_to_classes_page() \
            .accept_join_request(student_email) \
            .save() \
            .return_to_classes()

        assert classes_page.student_exists(student_name)
    def test_join_class(self):
        teacher_email, teacher_password = signup_teacher_directly()
        organisation_name, postcode = create_organisation_directly(
            teacher_email)
        klass, class_name, accesss_code = create_class_directly(teacher_email)
        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)

        logged_out_homepage = page.logout()

        classes_page = logged_out_homepage \
            .go_to_teach_page() \
            .login(teacher_email, teacher_password) \
            .go_to_classes_page() \
            .accept_join_request(student_email) \
            .save() \
            .return_to_classes()

        assert classes_page.student_exists(student_name)
Exemplo n.º 15
0
    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')
Exemplo n.º 16
0
    def test_populating_invalid_postcodes(self, mock_lookup_country):
        # Setting up mock
        values = {
            (u'AL10 9NE'): (None, 'GB', 'Hatfield', 51.7623259, -0.2438929),
            (u'-----'): (None, 'GB', '0', 55.378051, -3.435973),
            (u'yyyyy'): (None, 'GB', '0', 55.378051, -3.435973),
            (u''): (None, 'GB', '0', 55.378051, -3.435973),
        }

        def side_effect(args):
            return values[args]

        mock_lookup_country.side_effect = side_effect

        # Creating Data
        email_address, password = signup_teacher_directly()

        organisations = []
        # invalid postcodes
        organisations.append(
            create_organisation_directly(email_address, postcode='-----'))
        organisations.append(
            create_organisation_directly(email_address, postcode='yyyyy'))
        # as postcode should be required, this case in theory should not exist
        organisations.append(
            create_organisation_directly(email_address, postcode=''))

        # Migrating
        self.migrate_to_dest()

        # Assertion: check that schools with invalid postcode will be set to default value, 'UK'
        countries = {
            (u'AL10 9NE'): ('GB'),
            (u'-----'): ('GB'),
            (u'yyyyy'): ('GB'),
            (u''): ('GB'),
        }

        for organisation in organisations:
            school = School.objects.get(name=organisation[0])
            self.assertTrue(school.country, countries[school.postcode])
    def test_populating_valid_postcodes(self, mock_lookup_country):
        # Setting up mock
        values={(u'AL10 9NE'):(None, 'GB', 'Hatfield', 51.7623259, -0.2438929),
                (u'SW7 2AZ'):(None, 'GB', 'London', 51.5005046999999, -0.1782187),
                (u'CR3 7YA'):(None, 'GB', 'Caterham', 51.2763229, -0.051738),
                (u'10000'):(None, 'MX', 'Leon de los Aldama', 21.0859338, -101.5219684),
                (u'230-890'):(None, 'KR', 'Yeongwol-gun', 37.2382906, 128.5322833),
                (u'9446 PA'):(None, 'NL', 'Amen', 52.94067159999999, 6.6120059),
                }

        def side_effect(args):
            return values[args]

        mock_lookup_country.side_effect = side_effect

        # Creating Data
        email_address, password = signup_teacher_directly()

        organisations = []
        # Real postcodes from different countries
        organisations.append(create_organisation_directly(email_address, postcode = 'SW7 2AZ'))
        organisations.append(create_organisation_directly(email_address, postcode = 'CR3 7YA'))
        organisations.append(create_organisation_directly(email_address, postcode = '10000'))
        organisations.append(create_organisation_directly(email_address, postcode = '230-890'))
        organisations.append(create_organisation_directly(email_address, postcode = '9446 PA'))

        # Migrating
        self.migrate_to_dest()

        # Assertion: check that all the country fields are populated
        countries={(u'AL10 9NE'):('GB'),
                   (u'SW7 2AZ'):('GB'),
                   (u'CR3 7YA'):('GB'),
                   (u'10000'):('MX'),
                   (u'230-890'):('KR'),
                   (u'9446 PA'):('NL'),
                   }
        for organisation in organisations:
            school = School.objects.get(name=organisation[0])
            self.assertTrue(school.country, countries[school.postcode])
    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_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_populating_invalid_postcodes(self, mock_lookup_country):
        # Setting up mock
        values={(u'AL10 9NE'):(None, 'GB', 'Hatfield', 51.7623259, -0.2438929),
                (u'-----'):(None, 'GB', '0', 55.378051, -3.435973),
                (u'yyyyy'):(None, 'GB', '0', 55.378051, -3.435973),
                (u''):(None, 'GB', '0', 55.378051, -3.435973),
                }

        def side_effect(args):
            return values[args]

        mock_lookup_country.side_effect = side_effect

        # Creating Data
        email_address, password = signup_teacher_directly()

        organisations = []
        # invalid postcodes
        organisations.append(create_organisation_directly(email_address, postcode = '-----'))
        organisations.append(create_organisation_directly(email_address, postcode = 'yyyyy'))
        # as postcode should be required, this case in theory should not exist
        organisations.append(create_organisation_directly(email_address, postcode = ''))

        # Migrating
        self.migrate_to_dest()

        # Assertion: check that schools with invalid postcode will be set to default value, 'UK'
        countries={(u'AL10 9NE'):('GB'),
                (u'-----'):('GB'),
                (u'yyyyy'):('GB'),
                (u''):('GB'),
                }

        for organisation in organisations:
            school = School.objects.get(name=organisation[0])
            self.assertTrue(school.country, countries[school.postcode])