Ejemplo n.º 1
0
    def test_versions_empty_if_all_deleted(self):
        helpers.call_action('package_delete', id=self.v1['name'])
        helpers.call_action('package_delete', id=self.v2['name'])
        helpers.call_action('package_delete', id=self.v10['name'])

        dataset = helpers.call_action('package_show', id=self.parent['id'])

        assert_equals(dataset['_versions'], [])
Ejemplo n.º 2
0
    def test_parent_dataset_is_public_for_no_owner_org(self):
        helpers.call_action('dataset_version_create',
                            context={'user': self.user['name']},
                            id=self.v1['id'],
                            base_name='189-ma001')

        parent_dataset = helpers.call_action(
            'ckan_package_show',
            context={'user': self.user['name']},
            id='189-ma001')

        assert_equals(parent_dataset['private'], False)
Ejemplo n.º 3
0
    def test_versions_empty_if_all_deleted(self):
        helpers.call_action('package_delete',
                            id=self.v1['name'])
        helpers.call_action('package_delete',
                            id=self.v2['name'])
        helpers.call_action('package_delete',
                            id=self.v10['name'])

        dataset = helpers.call_action('package_show',
                                      id=self.parent['id'])

        assert_equals(dataset['_versions'], [])
    def test_parent_dataset_is_public_for_no_owner_org(self):
        helpers.call_action('dataset_version_create',
                            context={'user': self.user['name']},
                            id=self.v1['id'],
                            base_name='189-ma001')

        parent_dataset = helpers.call_action(
            'ckan_package_show',
            context={'user': self.user['name']},
            id='189-ma001')

        assert_equals(parent_dataset['private'], False)
Ejemplo n.º 5
0
    def test_parent_dataset_is_private_with_owner_org(self):
        helpers.call_action('dataset_version_create',
                            context={'user': self.user['name']},
                            id=self.v1['id'],
                            base_name='189-ma001',
                            owner_org=self.organization['id'])

        parent_dataset = helpers.call_action(
            'ckan_package_show',
            context={'user': self.user['name']},
            id='189-ma001')

        assert_equals(parent_dataset['private'], True)
    def test_parent_dataset_is_private_with_owner_org(self):
        helpers.call_action('dataset_version_create',
                            context={'user': self.user['name']},
                            id=self.v1['id'],
                            base_name='189-ma001',
                            owner_org=self.organization['id'])

        parent_dataset = helpers.call_action(
            'ckan_package_show',
            context={'user': self.user['name']},
            id='189-ma001')

        assert_equals(parent_dataset['private'], True)
Ejemplo n.º 7
0
    def test_new_versions_associated_with_existing(self):
        helpers.call_action('dataset_version_create',
                            id=self.v1['id'],
                            base_name='189-ma001')

        helpers.call_action('dataset_version_create',
                            id=self.v2['id'],
                            base_name='189-ma001')

        helpers.call_action('dataset_version_create',
                            id=self.v10['id'],
                            base_name='189-ma001')

        [rel_1] = helpers.call_action('package_relationships_list',
                                      id=self.v1['id'],
                                      rel='child_of')

        [rel_2] = helpers.call_action('package_relationships_list',
                                      id=self.v2['id'],
                                      rel='child_of')

        [rel_10] = helpers.call_action('package_relationships_list',
                                       id=self.v10['id'],
                                       rel='child_of')

        assert_equals(rel_1['subject'], '189-ma001-1')
        assert_equals(rel_1['type'], 'child_of')
        assert_equals(rel_1['object'], '189-ma001')

        assert_equals(rel_2['subject'], '189-ma001-2')
        assert_equals(rel_2['type'], 'child_of')
        assert_equals(rel_2['object'], '189-ma001')

        assert_equals(rel_10['subject'], '189-ma001-10')
        assert_equals(rel_10['type'], 'child_of')
        assert_equals(rel_10['object'], '189-ma001')
Ejemplo n.º 8
0
    def test_child_version_displayed_when_showing_child(self):
        dataset = helpers.call_action('package_show', id=self.v2['id'])

        assert_equals(dataset['name'], self.v2['name'])
Ejemplo n.º 9
0
    def test_latest_version_displayed_when_showing_parent(self):
        dataset = helpers.call_action('package_show', id=self.parent['id'])

        assert_equals(dataset['name'], self.v10['name'])
Ejemplo n.º 10
0
    def test_can_see_latest_version_when_logged_out(self):
        dataset = helpers.call_action('package_show',
                                      self.logged_out_context,
                                      id=self.parent['id'])

        assert_equals(dataset['name'], self.v10['name'])
Ejemplo n.º 11
0
    def test_versions_dont_accumulate(self):
        [rel_10] = helpers.call_action('package_relationships_list',
                                       id=self.v10['id'],
                                       rel='child_of')

        assert_equals(rel_10['subject'], '189-ma001-10')
        assert_equals(rel_10['type'], 'child_of')
        assert_equals(rel_10['object'], '189-ma001')

        dataset_dict = helpers.call_action('package_show', id='189-ma001')

        updated_dict = helpers.call_action('package_update',
                                           context={'user': self.user['id']},
                                           **dataset_dict)

        [rel_10] = helpers.call_action('package_relationships_list',
                                       id=self.v10['id'],
                                       rel='child_of')

        assert_equals(rel_10['subject'], '189-ma001-10')
        assert_equals(rel_10['type'], 'child_of')
        assert_equals(rel_10['object'], '189-ma001')

        assert_true('_versions' in updated_dict)

        # Versions would appear twice here if they accumulated, or they would
        # if the validators didn't complain
        self.assert_version_names(updated_dict, [
            self.v10['name'],
            self.v2['name'],
            self.v1['name'],
        ])
Ejemplo n.º 12
0
    def test_child_version_displayed_when_showing_child(self):
        dataset = helpers.call_action('package_show',
                                      id=self.v2['id'])

        assert_equals(dataset['name'], self.v2['name'])
Ejemplo n.º 13
0
    def test_latest_version_displayed_when_showing_parent(self):
        dataset = helpers.call_action('package_show',
                                      id=self.parent['id'])

        assert_equals(dataset['name'], self.v10['name'])
Ejemplo n.º 14
0
    def test_can_see_latest_version_when_logged_out(self):
        dataset = helpers.call_action('package_show',
                                      self.logged_out_context,
                                      id=self.parent['id'])

        assert_equals(dataset['name'], self.v10['name'])
Ejemplo n.º 15
0
    def test_versions_dont_accumulate(self):
        [rel_10] = helpers.call_action(
            'package_relationships_list',
            id=self.v10['id'],
            rel='child_of')

        assert_equals(rel_10['subject'], '189-ma001-10')
        assert_equals(rel_10['type'], 'child_of')
        assert_equals(rel_10['object'], '189-ma001')

        dataset_dict = helpers.call_action('package_show',
                                           id='189-ma001')

        updated_dict = helpers.call_action('package_update',
                                           context={'user': self.user['id']},
                                           **dataset_dict)

        [rel_10] = helpers.call_action(
            'package_relationships_list',
            id=self.v10['id'],
            rel='child_of')

        assert_equals(rel_10['subject'], '189-ma001-10')
        assert_equals(rel_10['type'], 'child_of')
        assert_equals(rel_10['object'], '189-ma001')

        assert_true('_versions' in updated_dict)

        # Versions would appear twice here if they accumulated, or they would
        # if the validators didn't complain
        self.assert_version_names(updated_dict, [
            self.v10['name'],
            self.v2['name'],
            self.v1['name'],
        ])
Ejemplo n.º 16
0
    def test_new_versions_associated_with_existing(self):
        helpers.call_action('dataset_version_create',
                            id=self.v1['id'],
                            base_name='189-ma001')

        helpers.call_action('dataset_version_create',
                            id=self.v2['id'],
                            base_name='189-ma001')

        helpers.call_action('dataset_version_create',
                            id=self.v10['id'],
                            base_name='189-ma001')

        [rel_1] = helpers.call_action(
            'package_relationships_list',
            id=self.v1['id'],
            rel='child_of')

        [rel_2] = helpers.call_action(
            'package_relationships_list',
            id=self.v2['id'],
            rel='child_of')

        [rel_10] = helpers.call_action(
            'package_relationships_list',
            id=self.v10['id'],
            rel='child_of')

        assert_equals(rel_1['subject'], '189-ma001-1')
        assert_equals(rel_1['type'], 'child_of')
        assert_equals(rel_1['object'], '189-ma001')

        assert_equals(rel_2['subject'], '189-ma001-2')
        assert_equals(rel_2['type'], 'child_of')
        assert_equals(rel_2['object'], '189-ma001')

        assert_equals(rel_10['subject'], '189-ma001-10')
        assert_equals(rel_10['type'], 'child_of')
        assert_equals(rel_10['object'], '189-ma001')