예제 #1
0
    def test_version_number_errors_for_get_multiple_exploration_versions(self):
        # Update exploration to version 2.
        change_list = [
            exp_domain.ExplorationChange({
                'cmd': exp_domain.CMD_ADD_STATE,
                'state_name': 'New state',
            })
        ]
        exp_services.update_exploration(feconf.SYSTEM_COMMITTER_ID,
                                        self.EXP_1_ID, change_list, '')

        # Update exploration to version 3.
        change_list = [
            exp_domain.ExplorationChange({
                'cmd': exp_domain.CMD_ADD_STATE,
                'state_name': 'New state 2',
            })
        ]
        exp_services.update_exploration(feconf.SYSTEM_COMMITTER_ID,
                                        self.EXP_1_ID, change_list, '')

        with self.assertRaisesRegexp(
                ValueError,
                'Requested version number 4 cannot be higher than the current '
                'version number 3.'):
            exp_fetchers.get_multiple_explorations_by_version(
                self.EXP_1_ID, [1, 2, 3, 4])

        with self.assertRaisesRegexp(ValueError,
                                     'At least one version number is invalid'):
            exp_fetchers.get_multiple_explorations_by_version(
                self.EXP_1_ID, [1, 2, 2.5, 3])
예제 #2
0
    def test_retrieval_of_multiple_exploration_versions(self):
        # Update exploration to version 2.
        change_list = [
            exp_domain.ExplorationChange({
                'cmd': exp_domain.CMD_ADD_STATE,
                'state_name': 'New state',
            })
        ]
        exp_services.update_exploration(feconf.SYSTEM_COMMITTER_ID,
                                        self.EXP_1_ID, change_list, '')

        # Update exploration to version 3.
        change_list = [
            exp_domain.ExplorationChange({
                'cmd': exp_domain.CMD_ADD_STATE,
                'state_name': 'New state 2',
            })
        ]
        exp_services.update_exploration(feconf.SYSTEM_COMMITTER_ID,
                                        self.EXP_1_ID, change_list, '')

        exploration_latest = exp_fetchers.get_exploration_by_id(self.EXP_1_ID)
        latest_version = exploration_latest.version

        explorations = exp_fetchers.get_multiple_explorations_by_version(
            self.EXP_1_ID, list(python_utils.RANGE(1, latest_version + 1)))

        self.assertEqual(len(explorations), 3)
        self.assertEqual(explorations[0].version, 1)
        self.assertEqual(explorations[1].version, 2)
        self.assertEqual(explorations[2].version, 3)
예제 #3
0
 def test_retrieval_of_multiple_exploration_versions_for_fake_exp_id(self):
     with self.assertRaisesRegexp(
             ValueError, 'The given entity_id fake_exp_id is invalid'):
         exp_fetchers.get_multiple_explorations_by_version(
             'fake_exp_id', [1, 2, 3])