Пример #1
0
def _is_descriptor_mobile_available(descriptor):
    """
    Returns if descriptor is available on mobile.
    """
    if IgnoreMobileAvailableFlagConfig.is_enabled() or descriptor.mobile_available:
        return ACCESS_GRANTED
    else:
        return MobileAvailabilityError()
Пример #2
0
 def setUp(self):
     super(MobileAPITestCase, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.course = CourseFactory.create(
         mobile_available=True,
         static_asset_path="needed_for_split",
         end=datetime.datetime.now(pytz.UTC),
         certificate_available_date=datetime.datetime.now(pytz.UTC))
     self.user = UserFactory.create()
     self.password = '******'
     self.username = self.user.username
     self.api_version = API_V1
     IgnoreMobileAvailableFlagConfig(enabled=False).save()
Пример #3
0
    def test_non_mobile_available(self, role, should_succeed):
        """
        Tests that the MobileAvailabilityError() is raised for certain user
        roles when trying to access course content. Also verifies that if
        the IgnoreMobileAvailableFlagConfig is enabled,
        MobileAvailabilityError() will not be raised for all user roles.
        """
        self.init_course_access()
        # set mobile_available to False for the test course
        self.course.mobile_available = False
        self.store.update_item(self.course, self.user.id)
        self._verify_response(should_succeed, MobileAvailabilityError(), role)

        IgnoreMobileAvailableFlagConfig(enabled=True).save()
        self._verify_response(True, MobileAvailabilityError(), role)