Пример #1
0
 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')
Пример #2
0
 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')
Пример #3
0
 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'))
Пример #4
0
 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'))
Пример #5
0
    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([]))
Пример #6
0
    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([]))
Пример #7
0
    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",)))
Пример #8
0
    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', )))
Пример #10
0
 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)),
                  [])
Пример #11
0
 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'])
Пример #12
0
 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'])
Пример #13
0
 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())
Пример #14
0
 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')))
Пример #15
0
 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')))
Пример #16
0
 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'])
Пример #17
0
    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']))
Пример #18
0
 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'])
Пример #19
0
 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())
Пример #20
0
 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)),
                  [])
Пример #21
0
    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']))
Пример #22
0
 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'])
Пример #23
0
 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'])
Пример #24
0
 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'])
Пример #25
0
 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')))
Пример #26
0
 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')))
Пример #27
0
 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'])