Esempio n. 1
0
    def test_view_non_object_user(self):
        # created by a script, but no User object exists
        user = '******'

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), 'Staff')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), 'random')
Esempio n. 2
0
    def test_view_non_object_user(self):
        # created by a script, but no User object exists
        user = '******'

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), 'Staff')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), 'random')
Esempio n. 3
0
    def test_view_old_drupal_edit(self):
        # Up til Jun 2012, edits through drupal were saved like this
        # "NHS North Staffordshire (uid 6107 )"
        user = '******'

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), '<a href="/publisher/national-health-service">National Heal...</a>')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), '<a href="/data/user/user_d101">NHS Editor im...</a>')
Esempio n. 4
0
    def test_view_system_user(self):
        # created on the API
        user_dict = get_action('get_site_user')({'model': model, 'ignore_auth': True}, {})
        user = user_dict['name']

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), 'System Process')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user, maxlength=100)),
                '<a href="/data/user/test.ckan.net">System Process (Site user)</a>')
Esempio n. 5
0
    def test_view_system_user(self):
        # created on the API
        user_dict = get_action('get_site_user')({'model': model, 'ignore_auth': True}, {})
        user = user_dict['name']

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), 'System Process')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user, maxlength=100)),
                '<a href="/data/user/test.ckan.net">System Process (Site user)</a>')
Esempio n. 6
0
    def test_view_sysadmin(self):
        # very common case
        user = "******"
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), "System Administrator")
        assert_equal(str(dgu_linked_user(user_obj)), "System Administrator")

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), '<a href="/data/user/sysadmin">Test Sysadmin</a>')
        assert_equal(str(dgu_linked_user(user_obj)), '<a href="/data/user/sysadmin">Test Sysadmin</a>')
Esempio n. 7
0
    def test_view_old_drupal_edit(self):
        # Up til Jun 2012, edits through drupal were saved like this
        # "NHS North Staffordshire (uid 6107 )"
        user = '******'

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/publisher/national-health-service">National Health Service</a>')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/data/user/user_d101">NHS Editor imported f...</a>')
Esempio n. 8
0
    def test_view_non_object_user(self):
        # created by a script, but no User object exists
        user = '******'

        with regular_user():
            assert_equal(str(dgu_linked_user(user)), 'Staff')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)), 'random')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)), 'random')
Esempio n. 9
0
    def test_view_non_object_user(self):
        # created by a script, but no User object exists
        user = '******'

        with regular_user():
            assert_equal(str(dgu_linked_user(user)), 'Staff')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)), 'random')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)), 'random')
Esempio n. 10
0
    def test_view_member_of_public(self):
        # most common case
        user = "******"  # a member of the public, not anonymous - public comments
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), '<a href="/users/102">John Doe - a public user</a>')
        assert_equal(str(dgu_linked_user(user_obj)), '<a href="/users/102">John Doe - a public user</a>')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), '<a href="/users/102">John Doe - a public user</a>')
        assert_equal(str(dgu_linked_user(user_obj)), '<a href="/users/102">John Doe - a public user</a>')
Esempio n. 11
0
    def test_view_drupal_user(self):
        # most common case
        user = '******'
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), '<a href="/publisher/national-health-service">National Heal...</a>')
        assert_equal(str(dgu_linked_user(user_obj)), '<a href="/publisher/national-health-service">National Heal...</a>')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), '<a href="/data/user/nhseditor">NHS Editor</a>')
        assert_equal(str(dgu_linked_user(user_obj)), '<a href="/data/user/nhseditor">NHS Editor</a>')
Esempio n. 12
0
    def test_view_system_user(self):
        # created on the API
        user_dict = get_action("get_site_user")({"model": model, "ignore_auth": True}, {})
        user = user_dict["name"]

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), "System Process")

        c.is_an_official = True
        assert_equal(
            str(dgu_linked_user(user, maxlength=100)),
            '<a href="/data/user/test.ckan.net">System Process (Site user)</a>',
        )
Esempio n. 13
0
    def test_view_sysadmin(self):
        # very common case
        user = '******'
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)), 'System Administrator')
        assert_equal(str(dgu_linked_user(user_obj)), 'System Administrator')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/data/user/sysadmin">Test Sysadmin</a>')
        assert_equal(str(dgu_linked_user(user_obj)),
                '<a href="/data/user/sysadmin">Test Sysadmin</a>')
Esempio n. 14
0
    def test_view_system_user(self):
        # created on the API
        user_dict = get_action('get_site_user')({'model': model, 'ignore_auth': True}, {})
        user = user_dict['name']

        with regular_user():
            assert_equal(str(dgu_linked_user(user)), 'System Process')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user, maxlength=100)),
                '<a href="/data/user/test.ckan.net">System Process (Site user)</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user, maxlength=100)),
                '<a href="/data/user/test.ckan.net">System Process (Site user)</a>')
Esempio n. 15
0
    def test_view_official(self):
        # most common case
        user = '******' # i.e. an official, needing anonymity to the public
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/publisher/national-health-service">National Health Service</a>')
        assert_equal(str(dgu_linked_user(user_obj)),
                '<a href="/publisher/national-health-service">National Health Service</a>')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/data/user/nhseditor">NHS Editor</a>')
        assert_equal(str(dgu_linked_user(user_obj)),
                '<a href="/data/user/nhseditor">NHS Editor</a>')
Esempio n. 16
0
    def test_view_old_drupal_edit(self):
        # Up til Jun 2012, edits through drupal were saved like this
        # "NHS North Staffordshire (uid 6107 )"
        user = '******'

        with regular_user():
            assert_equal(str(dgu_linked_user(user)),
                '<a href="/publisher/national-health-service">National Health Service</a>')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                '<a href="/user/101">NHS Editor imported f...</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                '<a href="/user/101">NHS Editor imported f...</a>')
Esempio n. 17
0
    def test_view_member_of_public(self):
        # most common case
        user = '******' # a member of the public, not anonymous - public comments
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/users/102">John Doe - a public user</a>')
        assert_equal(str(dgu_linked_user(user_obj)),
                '<a href="/users/102">John Doe - a public user</a>')

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)),
                '<a href="/users/102">John Doe - a public user</a>')
        assert_equal(str(dgu_linked_user(user_obj)),
                '<a href="/users/102">John Doe - a public user</a>')
Esempio n. 18
0
    def test_view_official(self):
        # most common case
        user = "******"  # i.e. an official, needing anonymity to the public
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(
            str(dgu_linked_user(user)), '<a href="/publisher/national-health-service">National Health Service</a>'
        )
        assert_equal(
            str(dgu_linked_user(user_obj)), '<a href="/publisher/national-health-service">National Health Service</a>'
        )

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)), '<a href="/data/user/nhseditor">NHS Editor</a>')
        assert_equal(str(dgu_linked_user(user_obj)), '<a href="/data/user/nhseditor">NHS Editor</a>')
Esempio n. 19
0
    def test_view_old_drupal_edit(self):
        # Up til Jun 2012, edits through drupal were saved like this
        # "NHS North Staffordshire (uid 6107 )"
        user = '******'

        with regular_user():
            assert_equal(
                str(dgu_linked_user(user)),
                '<a href="/publisher/national-health-service">National Health Service</a>'
            )

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/user/101">NHS Editor imported f...</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/user/101">NHS Editor imported f...</a>')
Esempio n. 20
0
    def test_view_drupal_user(self):
        # most common case
        user = '******'
        user_obj = model.User.by_name(unicode(user))

        c.is_an_official = False
        assert_equal(
            str(dgu_linked_user(user)),
            '<a href="/publisher/national-health-service">National Heal...</a>'
        )
        assert_equal(
            str(dgu_linked_user(user_obj)),
            '<a href="/publisher/national-health-service">National Heal...</a>'
        )

        c.is_an_official = True
        assert_equal(str(dgu_linked_user(user)),
                     '<a href="/data/user/nhseditor">NHS Editor</a>')
        assert_equal(str(dgu_linked_user(user_obj)),
                     '<a href="/data/user/nhseditor">NHS Editor</a>')
Esempio n. 21
0
    def test_view_system_user(self):
        # created on the API
        user_dict = get_action('get_site_user')({
            'model': model,
            'ignore_auth': True
        }, {})
        user = user_dict['name']

        with regular_user():
            assert_equal(str(dgu_linked_user(user)), 'System Process')

        with publisher_user():
            assert_equal(
                str(dgu_linked_user(user, maxlength=100)),
                '<a href="/data/user/test.ckan.net">System Process (Site user)</a>'
            )

        with sysadmin_user():
            assert_equal(
                str(dgu_linked_user(user, maxlength=100)),
                '<a href="/data/user/test.ckan.net">System Process (Site user)</a>'
            )
Esempio n. 22
0
    def test_view_sysadmin(self):
        # very common case
        user = '******'
        user_obj = model.User.by_name(unicode(user))

        with regular_user():
            assert_equal(str(dgu_linked_user(user)), 'System Administrator')
            assert_equal(str(dgu_linked_user(user_obj)), 'System Administrator')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/data/user/sysadmin">Test Sysadmin</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/data/user/sysadmin">Test Sysadmin</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/data/user/sysadmin">Test Sysadmin</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/data/user/sysadmin">Test Sysadmin</a>')
Esempio n. 23
0
    def test_view_sysadmin(self):
        # very common case
        user = '******'
        user_obj = model.User.by_name(unicode(user))

        with regular_user():
            assert_equal(str(dgu_linked_user(user)), 'System Administrator')
            assert_equal(str(dgu_linked_user(user_obj)),
                         'System Administrator')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/data/user/sysadmin">Test Sysadmin</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                         '<a href="/data/user/sysadmin">Test Sysadmin</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/data/user/sysadmin">Test Sysadmin</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                         '<a href="/data/user/sysadmin">Test Sysadmin</a>')
Esempio n. 24
0
    def test_view_member_of_public(self):
        # most common case
        user = '******'  # a member of the public, not anonymous - public comments
        user_obj = model.User.by_name(unicode(user))

        with regular_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/user/102">John Doe - a public user</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                         '<a href="/user/102">John Doe - a public user</a>')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/user/102">John Doe - a public user</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                         '<a href="/user/102">John Doe - a public user</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                         '<a href="/user/102">John Doe - a public user</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                         '<a href="/user/102">John Doe - a public user</a>')
Esempio n. 25
0
    def test_view_member_of_public(self):
        # most common case
        user = '******' # a member of the public, not anonymous - public comments
        user_obj = model.User.by_name(unicode(user))

        with regular_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/user/102">John Doe - a public user</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/user/102">John Doe - a public user</a>')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/user/102">John Doe - a public user</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/user/102">John Doe - a public user</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/user/102">John Doe - a public user</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/user/102">John Doe - a public user</a>')
Esempio n. 26
0
    def test_view_official(self):
        # most common case
        user = '******' # i.e. an official, needing anonymity to the public
        user_obj = model.User.by_name(unicode(user))

        with regular_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/publisher/national-health-service">National Health Service</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/publisher/national-health-service">National Health Service</a>')

        with publisher_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/data/user/nhseditor">NHS Editor</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/data/user/nhseditor">NHS Editor</a>')

        with sysadmin_user():
            assert_equal(str(dgu_linked_user(user)),
                    '<a href="/data/user/nhseditor">NHS Editor</a>')
            assert_equal(str(dgu_linked_user(user_obj)),
                    '<a href="/data/user/nhseditor">NHS Editor</a>')