Example #1
0
    def setUp(self):
        super(LearnerLogAPITests, self).setUp()

        self.admin_data = {"username": "******", "password": "******"}
        self.admin = self.create_admin(**self.admin_data)

        self.zone = self.create_zone()
        self.device_zone = self.create_device_zone(self.zone)
        self.facility = self.create_facility()

        self.group = self.create_group(name='group1', facility=self.facility)
        self.empty_group = self.create_group(name='empty_group', facility=self.facility)

        self.facility_user = self.create_student()

        self.topic1 = create({
            "id": "stuff_here",
            "slug": "stuff_here",
            "path": "qwrqweqweqwe",
            "kind": "Topic",
            "title": "",
            "description": "",
            "available": True,
        })
        self.topic2 = create({
            "id": "stuff_there",
            "slug": "stuff_there",
            "path": "qwrqweqweqw",
            "kind": "Topic",
            "title": "",
            "description": "",
            "available": True,
        })

        self.exercise1 = create({
            "id": "stuff_here_ex",
            "slug": "stuff_here_ex",
            "path": "qwrqweqweqwe/qwrqweqweq",
            "kind": "Exercise",
            "title": "",
            "description": "",
            "available": True,
            "parent": self.topic1,
        })
        self.exercise2 = create({
            "id": "stuff_there_ex",
            "slug": "stuff_there_ex",
            "path": "qwrqweqweqw/qwrqweqw",
            "kind": "Exercise",
            "title": "",
            "description": "",
            "available": True,
            "parent": self.topic2,
        })

        self.create_exercise_log(user=self.facility_user, exercise_id=self.exercise1.id)
        self.create_exercise_log(user=self.facility_user, exercise_id=self.exercise2.id)
Example #2
0
def _make_video(context):
    root = get({"parent": None})
    lang_code = "en"
    youtube_id = "my_cool_id"
    item_dict = {
        "title": "Subtitled Video",
        "description": "A video with subtitles",
        "available": True,
        "kind": "Video",
        "id": "video_with_subtitles",
        "slug": "video_with_subtitles",
        "path": "khan/video_with_subtitles",
        "extra_fields": {
            "subtitle_urls": [{"url": get_subtitle_url(youtube_id=youtube_id, code=lang_code),
                               "code": lang_code,
                               "name": "English"}],
            "content_urls": {"stream": "/foo", "stream_type": "video/mp4"},
        },
        "parent": root,
    }
    # `create` will quietly do nothing if the item already exists. Possible from pathological test runs.
    # So delete any identical Items first.
    delete_instances(ids=[item_dict["id"]])
    context.video = create(item_dict)

    subtitle_path = get_subtitle_file_path(lang_code=lang_code, youtube_id=youtube_id)
    with open(subtitle_path, "w") as f:
        f.write("foo")
    context._subtitle_file_path = subtitle_path
Example #3
0
 def setUp(self, db=None):
     self.db = db
     self.topic1 = create({
         "id": "stuff_here",
         "slug": "stuff_here",
         "path": "qwrqweqweqwe",
         "kind": "Topic",
         "title": "",
         "description": "",
         "available": True,
     })
     self.exercise1 = create({
         "id": "stuff_here_ex",
         "slug": "stuff_here_ex",
         "path": "qwrqweqweqwe/qwrqweqweq",
         "kind": "Exercise",
         "title": "",
         "description": "",
         "available": True,
         "parent": self.topic1,
     })
     self.student = self.create_student()
     self.ex_logs = self.create_exercise_log(user=self.student, exercise_id=self.exercise1.id)
Example #4
0
def _make_video(context):
    root = get({"parent": None})
    lang_code = "en"
    youtube_id = "my_cool_id"
    item_dict = {
        "title": "Subtitled Video",
        "description": "A video with subtitles",
        "available": True,
        "kind": "Video",
        "id": "video_with_subtitles",
        "slug": "video_with_subtitles",
        "path": "khan/video_with_subtitles",
        "extra_fields": {
            "subtitle_urls": [{
                "url":
                get_subtitle_url(youtube_id=youtube_id, code=lang_code),
                "code":
                lang_code,
                "name":
                "English"
            }],
            "content_urls": {
                "stream": "/foo",
                "stream_type": "video/mp4"
            },
        },
        "parent": root,
    }
    # `create` will quietly do nothing if the item already exists. Possible from pathological test runs.
    # So delete any identical Items first.
    delete_instances(ids=[item_dict["id"]])
    context.video = create(item_dict)

    subtitle_path = get_subtitle_file_path(lang_code=lang_code,
                                           youtube_id=youtube_id)
    subtitle_dir = os.path.dirname(subtitle_path)
    if not os.path.exists(subtitle_dir):
        os.makedirs(subtitle_dir)
    with open(subtitle_path, "w") as f:
        f.write("foo")
    context._subtitle_file_path = subtitle_path