Ejemplo n.º 1
0
    def test_initialization(self):
        """Testing init method."""
        learner_playlist = (user_domain.LearnerPlaylist(
            'user_id0', ['exp_id0'], ['collect_id0']))

        self.assertEqual(learner_playlist.id, 'user_id0')
        self.assertListEqual(learner_playlist.exploration_ids, ['exp_id0'])
        self.assertListEqual(learner_playlist.collection_ids, ['collect_id0'])
Ejemplo n.º 2
0
    def test_remove_collection_id(self):
        """Testing remove_collection_id."""
        learner_playlist = (user_domain.LearnerPlaylist(
            'user_id0', ['exp_id0'], ['collect_id0']))

        self.assertListEqual(learner_playlist.collection_ids, ['collect_id0'])

        learner_playlist.remove_collection_id('collect_id0')

        self.assertListEqual(learner_playlist.collection_ids, [])
Ejemplo n.º 3
0
    def test_add_collection_id_list(self):
        """Testing add_collection_id."""
        learner_playlist = (user_domain.LearnerPlaylist(
            'user_id0', ['exp_id0'], ['collect_id0']))

        self.assertListEqual(learner_playlist.collection_ids, ['collect_id0'])

        learner_playlist.add_collection_id_to_list('collect_id1')

        self.assertListEqual(learner_playlist.collection_ids,
                             ['collect_id0', 'collect_id1'])
Ejemplo n.º 4
0
    def test_insert_exploration_id_at_given_position(self):
        """Testing inserting the given exploration id at the given position."""
        learner_playlist = (user_domain.LearnerPlaylist(
            'user_id0', ['exp_id0'], ['collect_id0']))

        self.assertListEqual(learner_playlist.exploration_ids, ['exp_id0'])

        learner_playlist.insert_exploration_id_at_given_position('exp_id1', 1)
        learner_playlist.insert_exploration_id_at_given_position('exp_id2', 1)

        self.assertListEqual(learner_playlist.exploration_ids,
                             ['exp_id0', 'exp_id2', 'exp_id1'])
Ejemplo n.º 5
0
def get_learner_playlist_from_model(learner_playlist_model):
    """Returns the learner playlist domain object given the learner playlist
    model loaded from the datastore.

    Args:
        learner_playlist_model: LearnerPlaylistModel. The
            learner playlist model from the datastore.

    Returns:
        LearnerPlaylist. The learner playlist domain object corresponding to the
        given model.
    """
    return user_domain.LearnerPlaylist(learner_playlist_model.id,
                                       learner_playlist_model.exploration_ids,
                                       learner_playlist_model.collection_ids)