def test_get_children_group_hierarchy__from_top_2(self): groups = model.Group.by_name(u'department-of-health').\ get_children_group_hierarchy(type=group_type) # the first group must be NHS or Food Standards Agency - i.e. on the # first level down nhs = groups[0] assert_in(nhs[1], ('national-health-service', 'food-standards-agency')) assert_equal(model.Group.get(nhs[3]).name, 'department-of-health')
def test_get_children_groups(self): res = model.Group.by_name(u'department-of-health').\ get_children_groups(type=group_type) # check groups assert_equal(name_set_from_groups(res), set(('national-health-service', 'food-standards-agency'))) # check each group is a Group assert isinstance(res[0], model.Group) assert_in(res[0].name, ('national-health-service', 'food-standards-agency')) assert_in(res[0].title, ('National Health Service', 'Food Standards Agency'))
def test_search_by_name_or_title_only_returns_active_groups(self): model.repo.new_revision() active_group = model.Group(name=u'active_group') active_group.state = u'active' inactive_group = model.Group(name=u'inactive_group') inactive_group.state = u'inactive' model.Session.add(active_group) model.Session.add(inactive_group) model.repo.commit_and_remove() assert_equal(self._search_results('active_group'), set(['active_group'])) assert_equal(self._search_results('inactive_group'), set([]))
def test_19_package_tag_list_save_duplicates(self): name = u"testpkg19" context = {"model": model, "session": model.Session} pkg_dict = {"name": name} rev = model.repo.new_revision() package = table_dict_save(pkg_dict, model.Package, context) tag_dicts = [{"name": "tag1"}, {"name": "tag1"}] # duplicate package_tag_list_save(tag_dicts, package, context) model.repo.commit_and_remove() pkg = model.Package.by_name(name) assert_equal(set([tag.name for tag in pkg.get_tags()]), set(("tag1",)))
def test_19_package_tag_list_save_duplicates(self): name = u'testpkg19' context = {'model': model, 'session': model.Session} pkg_dict = {'name': name} rev = model.repo.new_revision() package = table_dict_save(pkg_dict, model.Package, context) tag_dicts = [{'name': 'tag1'}, {'name': 'tag1'}] # duplicate package_tag_list_save(tag_dicts, package, context) model.repo.commit_and_remove() pkg = model.Package.by_name(name) assert_equal(set([tag.name for tag in pkg.get_tags()]), set(('tag1',)))
def test_19_package_tag_list_save_duplicates(self): name = u'testpkg19' context = {'model': model, 'session': model.Session} pkg_dict = {'name': name} rev = model.repo.new_revision() package = table_dict_save(pkg_dict, model.Package, context) tag_dicts = [{'name': 'tag1'}, {'name': 'tag1'}] # duplicate package_tag_list_save(tag_dicts, package, context) model.repo.commit_and_remove() pkg = model.Package.by_name(name) assert_equal(set([tag.name for tag in pkg.get_tags()]), set( ('tag1', )))
def test_get_parent_groups_up_hierarchy__from_top(self): assert_equal(names_from_groups(model.Group.by_name(u'department-of-health').\ get_parent_group_hierarchy(type=group_type)), [])
def test_get_parents__tier_three(self): assert_equal(names_from_groups(model.Group.by_name(u'nhs-wirral-ccg').\ get_parent_groups(type=group_type)), ['national-health-service'])
def test_get_parents__tier_two(self): assert_equal(names_from_groups(model.Group.by_name(u'national-health-service').\ get_parent_groups(type=group_type)), ['department-of-health'])
def test_get_children_group_hierarchy__from_bottom_tier(self): assert_equal(name_set_from_group_tuple(model.Group.by_name(u'nhs-wirral-ccg').\ get_children_group_hierarchy(type=group_type)), set())
def test_get_children_group_hierarchy__from_tier_two(self): assert_equal(name_set_from_group_tuple(model.Group.by_name(u'national-health-service').\ get_children_group_hierarchy(type=group_type)), set(('nhs-wirral-ccg', 'nhs-southwark-ccg')))
def test_get_children_group_hierarchy__from_top(self): assert_equal(name_set_from_group_tuple(model.Group.by_name(u'department-of-health').\ get_children_group_hierarchy(type=group_type)), set(('national-health-service', 'food-standards-agency', 'nhs-wirral-ccg', 'nhs-southwark-ccg')))
def test_3_search(self): model.repo.new_revision() model.Session.add(model.Group(name=u'test_org', title=u'Test org', type=u'organization' )) model.repo.commit_and_remove() assert_equal(self._search_results('random'), set([])) assert_equal(self._search_results('david'), set(['david'])) assert_equal(self._search_results('roger'), set(['roger'])) assert_equal(self._search_results('roger '), set(['roger'])) assert_equal(self._search_results('David'), set(['david'])) assert_equal(self._search_results('Dave'), set(['david'])) assert_equal(self._search_results('Dave\'s'), set(['david'])) assert_equal(self._search_results('Dave\'s books'), set(['david'])) assert_equal(self._search_results('Books'), set(['david', 'roger'])) assert_equal(self._search_results('Books', is_org=True), set([])) assert_equal(self._search_results('Test', is_org=True), set(['test_org']))
def test_get_parent_groups_up_hierarchy__from_tier_three(self): assert_equal(names_from_groups(model.Group.by_name(u'nhs-wirral-ccg').\ get_parent_group_hierarchy(type=group_type)), ['department-of-health', 'national-health-service'])
def test_get_top_level_groups(self): assert_equal(names_from_groups(model.Group.by_name(u'nhs-wirral-ccg').\ get_top_level_groups(type=group_type)), ['cabinet-office', 'department-of-health'])