def setUpTestData(cls): provision_device() facility = cls.facility = FacilityFactory.create() cls.learner = FacilityUserFactory.create(facility=facility) cls.facility_coach = FacilityUserFactory.create(facility=facility) facility.add_role(cls.facility_coach, "coach") cls.class_coach = FacilityUserFactory.create(facility=facility) facility.add_role(cls.class_coach, "classroom assignable coach") cls.superuser = create_superuser(cls.facility)
def setUpTestData(cls): provision_device() cls.facility = FacilityFactory.create() cls.user = FacilityUserFactory(facility=cls.facility) cls.user2 = FacilityUserFactory(facility=cls.facility) cls.contentnode = ContentNode.objects.create( id=uuid.uuid4().hex, title="root", channel_id=uuid.uuid4().hex, content_id=uuid.uuid4().hex, )
def setUpTestData(cls): cls.facility = FacilityFactory.create() i = 1 user = FacilityUserFactory.create(facility=cls.facility) sess_logs = [] summ_logs = [] for _ in range(3): sess_logs.append( ContentSessionLogFactory.create( user=user, ) ) summ_logs.append( ContentSummaryLogFactory.create( user=user, ) ) ex_csessl = ContentSessionLogFactory.create( user=user, ) ex_csmlog = ContentSummaryLogFactory.create( user=user, ) masterylog = MasteryLogFactory.create(user=user, summarylog=ex_csmlog) attemptlog = AttemptLogFactory.create( user=user, masterylog=masterylog, sessionlog=ex_csessl ) usersessionlog = UserSessionLogFactory.create(user=user) sess_logs.append(ex_csessl) summ_logs.append(ex_csmlog) setattr(cls, "user_{}".format(str(i)), user) setattr(cls, "user_{}_sess_logs".format(str(i)), sess_logs) setattr(cls, "user_{}_summ_logs".format(str(i)), summ_logs) setattr(cls, "user_{}_masterylog".format(str(i)), masterylog) setattr(cls, "user_{}_attemptlog".format(str(i)), attemptlog) setattr(cls, "user_{}_usersessionlog".format(str(i)), usersessionlog) cls.user_1_id = cls.user_1.id cls.user_2 = FacilityUserFactory.create(facility=cls.facility) merge_users(cls.user_1, cls.user_2) merge_users(cls.user_1, cls.user_2)
def test_admin_responses(self): user = FacilityUserFactory.create() user.facility.add_role(user, role_kinds.ADMIN) self.check_responses(credentials={ "username": user.username, "password": DUMMY_PASSWORD })
def test_redirect_root_to_learn_if_logged_in(self): do = FacilityUserFactory.create() provision_device() self.client.login(username=do.username, password=DUMMY_PASSWORD) response = self.client.get(reverse("kolibri:core:root_redirect")) self.assertEqual(response.status_code, 302) self.assertEqual(response.get("location"), reverse("kolibri:kolibri.plugins.learn:learn"))
def test_user_permissions(self): self.user = FacilityUserFactory.create(facility=self.facility) self.client.logout() self.client.login( username=self.user.username, password=DUMMY_PASSWORD, facility=self.facility ) response = self.client.get(reverse("kolibri:core:deviceinfo"), format="json") self.assertEqual(response.status_code, 403)
def test_user_with_permissions(self): self.user = FacilityUserFactory.create(facility=self.facility) DevicePermissions.objects.create(user=self.user, can_manage_content=True) self.client.logout() self.client.login( username=self.user.username, password=DUMMY_PASSWORD, facility=self.facility ) response = self.client.get(reverse("kolibri:core:deviceinfo"), format="json") self.assertEqual(response.status_code, 200)
def setUp(self): provision_device() self.facility = FacilityFactory.create() self.superuser = create_superuser(self.facility) self.user = FacilityUserFactory.create(facility=self.facility) self.client.login( username=self.superuser.username, password=DUMMY_PASSWORD, facility=self.facility, )
def setUp(self): provision_device() self.facility = FacilityFactory.create() self.admin = FacilityUserFactory(facility=self.facility) self.facility.add_role(self.admin, role_kinds.ADMIN) self.user = FacilityUserFactory(facility=self.facility) self.client.login( username=self.admin.username, password=DUMMY_PASSWORD, facility=self.facility, ) data = { "id": "ping", "version_range": "<0.11.0", "timestamp": timezone.now(), "source": PINGBACK, } self.notification = PingbackNotification.objects.create(**data)
def setUp(self): super(DeviceNameTestCase, self).setUp() self.facility = FacilityFactory.create() provision_device(language_id="es", default_facility=self.facility) self.superuser = create_superuser(self.facility) self.user = FacilityUserFactory.create(facility=self.facility) self.client.login( username=self.superuser.username, password=DUMMY_PASSWORD, facility=self.facility, )
def setUp(self): provision_device() self.facility = FacilityFactory.create() self.superuser = create_superuser(self.facility) self.learner = FacilityUserFactory(facility=self.facility) self.existing_happy_netloc = models.NetworkLocation.objects.create( base_url="https://kolibrihappyurl.qqq/") self.existing_nonkolibri_netloc = models.NetworkLocation.objects.create( base_url="https://nonkolibrihappyurl.qqq/") self.existing_sad_netloc = models.NetworkLocation.objects.create( base_url="https://sadurl.qqq/")
def setUpTestData(cls): cls.settings = { "language_id": "en", "allow_guest_access": False, "allow_peer_unlisted_channel_import": True, "allow_learner_unassigned_resource_access": False, } cls.facility = FacilityFactory.create() provision_device(language_id="es", default_facility=cls.facility) cls.superuser = create_superuser(cls.facility) cls.user = FacilityUserFactory.create(facility=cls.facility)
def setUp(self): DeviceSettings.objects.create(is_provisioned=True) self.facility = Facility.objects.create(name="facility") admin = FacilityUserFactory(facility=self.facility) self.facility.add_admin(admin) self.client.login(username=admin.username, password=DUMMY_PASSWORD)
def setUpTestData(cls): cls.facility = FacilityFactory.create() content_identifiers = [(uuid.uuid4().hex, uuid.uuid4().hex) for i in range(3)] ex_identifiers = (uuid.uuid4().hex, uuid.uuid4().hex) for i in range(1, 3): user = FacilityUserFactory.create(facility=cls.facility) sess_logs = [] summ_logs = [] for channel_id, content_id in content_identifiers: sess_logs.append( ContentSessionLogFactory.create( user=user, channel_id=channel_id, content_id=content_id, ) ) summ_logs.append( ContentSummaryLogFactory.create( user=user, channel_id=channel_id, content_id=content_id, ) ) channel_id, content_id = ex_identifiers ex_csessl = ContentSessionLogFactory.create( user=user, channel_id=channel_id, content_id=content_id, ) ex_csmlog = ContentSummaryLogFactory.create( user=user, channel_id=channel_id, content_id=content_id, ) masterylog = MasteryLogFactory.create( user=user, summarylog=ex_csmlog, mastery_level=1 ) attemptlog = AttemptLogFactory.create( user=user, masterylog=masterylog, sessionlog=ex_csessl ) usersessionlog = UserSessionLogFactory.create(user=user) sess_logs.append(ex_csessl) summ_logs.append(ex_csmlog) setattr(cls, "user_{}".format(str(i)), user) setattr(cls, "user_{}_sess_logs".format(str(i)), sess_logs) setattr(cls, "user_{}_summ_logs".format(str(i)), summ_logs) setattr(cls, "user_{}_masterylog".format(str(i)), masterylog) setattr(cls, "user_{}_attemptlog".format(str(i)), attemptlog) setattr(cls, "user_{}_usersessionlog".format(str(i)), usersessionlog) cls.user_1_id = cls.user_1.id cls.user_1.birth_year = "1984" cls.user_1.id_number = "101" cls.user_1.save() cls.user_2.id_number = "13" cls.user_2.save() merge_users(cls.user_1, cls.user_2)
def setUpTestData(cls): cls.device_name = {"name": "test device"} cls.facility = FacilityFactory.create() provision_device(language_id="es", default_facility=cls.facility) cls.superuser = create_superuser(cls.facility) cls.user = FacilityUserFactory.create(facility=cls.facility)
def setUpTestData(cls): provision_device() cls.facility = FacilityFactory.create() cls.superuser = create_superuser(cls.facility) cls.user = FacilityUserFactory.create(facility=cls.facility)
def setUpTestData(cls): provision_device() cls.facility = FacilityFactory.create() cls.admin = FacilityUserFactory(facility=cls.facility) cls.facility.add_role(cls.admin, role_kinds.ADMIN) cls.user = FacilityUserFactory(facility=cls.facility)
def test_learner_responses(self): user = FacilityUserFactory.create() self.check_responses(credentials={ "username": user.username, "password": DUMMY_PASSWORD })