Esempio n. 1
0
 def test_groups_allowed_to_be_its_parent(self):
     groups = model.Group.by_name(u'national-health-service').\
         groups_allowed_to_be_its_parent(type=group_type)
     names = names_from_groups(groups)
     assert_in('department-of-health', names)
     assert_in('cabinet-office', names)
     assert_not_in('natonal-health-service', names)
     assert_not_in('nhs-wirral-ccg', names)
Esempio n. 2
0
 def test_groups_allowed_to_be_its_parent(self):
     groups = model.Group.by_name(u'national-health-service').\
         groups_allowed_to_be_its_parent(type=group_type)
     names = names_from_groups(groups)
     assert_in('department-of-health', names)
     assert_in('cabinet-office', names)
     assert_not_in('natonal-health-service', names)
     assert_not_in('nhs-wirral-ccg', names)
Esempio n. 3
0
    def test_21_package_dictization_with_deleted_group(self):
        """
        Ensure that the dictization does not return groups that the dataset has
        been removed from.
        """
        # Create a new dataset and 2 new groups
        model.repo.new_revision()
        pkg = model.Package(name='testing-deleted-groups')
        group_1 = model.Group(name='test-group-1')
        group_2 = model.Group(name='test-group-2')
        model.Session.add(pkg)
        model.Session.add(group_1)
        model.Session.add(group_2)
        model.Session.flush()

        # Add the dataset to group_1, and signal that the dataset used
        # to be a member of group_2 by setting its membership state to 'deleted'
        membership_1 = model.Member(table_id = pkg.id,
                                    table_name = 'package',
                                    group = group_1,
                                    group_id = group_1.id,
                                    state = 'active')

        membership_2 = model.Member(table_id = pkg.id,
                                    table_name = 'package',
                                    group = group_2,
                                    group_id = group_2.id,
                                    state = 'deleted')

        model.Session.add(membership_1)
        model.Session.add(membership_2)
        model.repo.commit()

        # Dictize the dataset
        context = {"model": model,
                   "session": model.Session}

        result = package_dictize(pkg, context)
        self.remove_changable_columns(result)
        assert_not_in('test-group-2', [ g['name'] for g in result['groups'] ])
        assert_in('test-group-1', [ g['name'] for g in result['groups'] ])
    def test_21_package_dictization_with_deleted_group(self):
        """
        Ensure that the dictization does not return groups that the dataset has
        been removed from.
        """
        # Create a new dataset and 2 new groups
        model.repo.new_revision()
        pkg = model.Package(name='testing-deleted-groups')
        group_1 = model.Group(name='test-group-1')
        group_2 = model.Group(name='test-group-2')
        model.Session.add(pkg)
        model.Session.add(group_1)
        model.Session.add(group_2)
        model.Session.flush()

        # Add the dataset to group_1, and signal that the dataset used
        # to be a member of group_2 by setting its membership state to 'deleted'
        membership_1 = model.Member(table_id=pkg.id,
                                    table_name='package',
                                    group=group_1,
                                    group_id=group_1.id,
                                    state='active')

        membership_2 = model.Member(table_id=pkg.id,
                                    table_name='package',
                                    group=group_2,
                                    group_id=group_2.id,
                                    state='deleted')

        model.Session.add(membership_1)
        model.Session.add(membership_2)
        model.repo.commit()

        # Dictize the dataset
        context = {"model": model, "session": model.Session}

        result = package_dictize(pkg, context)
        self.remove_changable_columns(result)
        assert_not_in('test-group-2', [g['name'] for g in result['groups']])
        assert_in('test-group-1', [g['name'] for g in result['groups']])