Exemple #1
0
 def get_course(cls, course_id):
     app_context = sites.get_course_for_path(course_id)
     if not app_context or app_context.get_slug() != course_id:
         return None
     if cls._is_visible(app_context):
         return Course(app_context, id=app_context.get_slug())
     return None
Exemple #2
0
 def get_course(cls, course_id):
     app_context = sites.get_course_for_path(course_id)
     if not app_context or app_context.get_slug() != course_id:
         return None
     if cls._is_visible(app_context):
         return Course(app_context, id=app_context.get_slug())
     return None
    def assert_guide_accesssible(self, name):
        response = self.get("/modules/guides")
        self.assertEquals(200, response.status_int)
        self.assertIn('category="Power Searching with Google [%s]' % name, response.body)

        app_ctx = sites.get_course_for_path("/%s" % name)
        course = courses.Course(None, app_context=app_ctx)
        for unit in course.get_units():
            if unit.type != verify.UNIT_TYPE_UNIT:
                continue
            response = self.get("/%s/guide?unit_id=%s" % (name, unit.unit_id))
            self.assertIn(unit.title, response.body.decode("utf-8"))
    def assert_guide_accesssible(self, name):
        response = self.get('/modules/guides')
        self.assertEquals(200, response.status_int)
        self.assertIn('category="Power Searching with Google [%s]' % name,
                      response.body)

        app_ctx = sites.get_course_for_path('/%s' % name)
        course = courses.Course(None, app_context=app_ctx)
        for unit in course.get_units():
            if unit.type != verify.UNIT_TYPE_UNIT:
                continue
            response = self.get('/%s/guide?unit_id=%s' % (name, unit.unit_id))
            self.assertIn(unit.title, response.body.decode('utf-8'))
    def assert_guide_not_accesssible(self, name, is_guides_accessible=False):
        response = self.get("/modules/guides", expect_errors=True)
        if is_guides_accessible:
            self.assertEquals(200, response.status_int)
        else:
            self.assertEquals(404, response.status_int)

        app_ctx = sites.get_course_for_path("/%s" % name)
        course = courses.Course(None, app_context=app_ctx)
        for unit in course.get_units():
            if unit.type != verify.UNIT_TYPE_UNIT:
                continue
            response = self.get("/%s/guide?unit_id=%s" % (name, unit.unit_id), expect_errors=True)
            self.assertEquals(404, response.status_int)
    def assert_guide_not_accesssible(self, name, is_guides_accessible=False):
        response = self.get('/modules/guides', expect_errors=True)
        if is_guides_accessible:
            self.assertEquals(200, response.status_int)
        else:
            self.assertEquals(404, response.status_int)

        app_ctx = sites.get_course_for_path('/%s' % name)
        course = courses.Course(None, app_context=app_ctx)
        for unit in course.get_units():
            if unit.type != verify.UNIT_TYPE_UNIT:
                continue
            response = self.get('/%s/guide?unit_id=%s' % (name, unit.unit_id),
                                expect_errors=True)
            self.assertEquals(404, response.status_int)