Example #1
0
    def test_returns_all_contents_and_exercises(self):
        topic_root = retrieve_kalite_topic_data()
        contents = retrieve_kalite_content_data()
        exercises = retrieve_kalite_exercise_data()

        topic_list = list(flatten_topic_tree(topic_root, contents, exercises))

        assert len(topic_list) >= len(contents) + len(exercises)
    def test_returns_something_in_production_json(self):
        """
        Since we know that test_given_list_returns_only_videos works, then
        we only need to check that we return something for the actual contents.json
        to make sure we're reading the right attributes.
        """
        content_data = retrieve_kalite_content_data()

        assert _get_video_ids(content_data)
    def test_translate_contents(self):
        content_data = retrieve_kalite_content_data()
        translated_content_data = translate_contents(
            content_data,
            self.ka_catalog,
        )

        for content_id in translated_content_data:
            for field in CONTENT_FIELDS_TO_TRANSLATE:
                translated_fieldval = translated_content_data[content_id][field]
                untranslated_fieldval = content_data[content_id][field]
                assert translated_fieldval == self.ka_catalog.msgid_mapping.get(untranslated_fieldval, "")
def _get_all_video_ids():
    """
    Test utility function so we only need to generate the list of video
    ids once, and then assign that to an instance variable. We
    wrap it as a function instead of assigning the value of
    retrieve_kalite_content_data directly so we can use the
    cassette system to cache the results, avoiding an expensive
    http request.

    """
    content_data = retrieve_kalite_content_data()

    ids = _get_video_ids(content_data)

    # return a tuple, to make sure it gets never modified.
    ids_tuple = tuple(ids)

    # just take the first 10 ids -- don't run too many
    return ids_tuple[:10]
Example #5
0
def generate_node_list():
    return flatten_topic_tree(
        retrieve_kalite_topic_data(),
        retrieve_kalite_content_data(),
        retrieve_kalite_exercise_data(),
    )
 def test_returns_dict(self):
     content_data = retrieve_kalite_content_data()
     assert isinstance(content_data, dict)