Example #1
0
    def setup_class(self):
        model.Session.remove()
        CreateTestData.create()
        self.name = u'revisiontest'

        # create pkg
        self.descriptions = [
            u'Written by Puccini', u'Written by Rossini',
            u'Not written at all', u'Written again', u'Written off'
        ]
        rev = model.repo.new_revision()
        self.grp = model.Group(name=self.name)
        model.Session.add(self.grp)
        self.grp.description = self.descriptions[0]
        self.grp.extras['mykey'] = self.descriptions[0]
        model.repo.commit_and_remove()

        # edit pkg
        for i in range(5)[1:]:
            rev = model.repo.new_revision()
            grp = model.Group.by_name(self.name)
            grp.description = self.descriptions[i]
            grp.extras['mykey'] = self.descriptions[i]
            model.repo.commit_and_remove()

        self.grp = model.Group.by_name(self.name)
Example #2
0
    def setup_class(cls):
        setup_test_search_index()
        # Force a garbage collection to trigger issue #695
        import gc
        gc.collect()

        CreateTestData.create()

        cls.new_pkg_dict = {
            'name':
            'council-owned-litter-bins',
            'notes':
            'Location of Council owned litter bins within Borough.',
            'resources': [{
                'description': 'Resource locator',
                'format': 'Unverified',
                'url': 'http://www.barrowbc.gov.uk'
            }],
            'tags': ['Utility and governmental services'],
            'title':
            'Council Owned Litter Bins',
            'extras': {
                'INSPIRE':
                'True',
                'bbox-east-long':
                '-3.12442',
                'bbox-north-lat':
                '54.218407',
                'bbox-south-lat':
                '54.039634',
                'bbox-west-long':
                '-3.32485',
                'constraint':
                'conditions unknown; (e) intellectual property rights;',
                'dataset-reference-date':
                json.dumps([{
                    'type': 'creation',
                    'value': '2008-10-10'
                }, {
                    'type': 'revision',
                    'value': '2009-10-08'
                }]),
                'guid':
                '00a743bf-cca4-4c19-a8e5-e64f7edbcadd',
                'metadata-date':
                '2009-10-16',
                'metadata-language':
                'eng',
                'published_by':
                0,
                'resource-type':
                'dataset',
                'spatial-reference-system':
                'test-spatial',
                'temporal_coverage-from':
                '1977-03-10T11:45:30',
                'temporal_coverage-to':
                '2005-01-15T09:10:00'
            }
        }
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': 'a',
             'extras': {
                 'department': 'abc',
                 'agency': 'ag-a'
             },
         },
         {
             'name': 'b',
             'extras': {
                 'department': 'bcd',
                 'agency': 'ag-b'
             },
         },
         {
             'name': 'c',
             'extras': {
                 'department': 'cde abc'
             },
         },
         {
             'name': 'none',
             'extras': {
                 'department': ''
             },
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Example #4
0
def initial_data(clean_db):

    # SmtpServerHarness.setup_class()
    CreateTestData.create()

    # make 3 changes, authored by annafan
    for i in range(3):
        pkg = model.Package.by_name(u"annakarenina")
        pkg.notes = u"Changed notes %i" % i
        model.repo.commit_and_remove()

    CreateTestData.create_user("unfinisher",
                               about='<a href="http://unfinished.tag')
    CreateTestData.create_user("uncloser",
                               about='<a href="http://unclosed.tag">')
    CreateTestData.create_user(
        "spammer",
        about=
        u'<a href="http://mysite">mysite</a> <a href=\u201dhttp://test2\u201d>test2</a>',
    )
    CreateTestData.create_user(
        "spammer2",
        about=
        u'<a href="http://spamsite1.com\u201d>spamsite1</a>\r\n<a href="http://www.spamsite2.com\u201d>spamsite2</a>\r\n',
    )
Example #5
0
 def test_perform_reset_user_password_link_key_missing(self):
     CreateTestData.create_user(name='jack', password='******')
     user = model.User.by_name(u'jack')
     offset = url_for(controller='user',
                      action='perform_reset',
                      id=user.id)  # not, no key specified
     res = self.app.get(offset, status=403) # error
Example #6
0
    def setup_class(cls):
        smtp_server = config.get('smtp.test_server')
        if smtp_server:
            host, port = smtp_server.split(':')
            port = int(port) + int(
                str(hashlib.md5(cls.__name__).hexdigest())[0], 16)
            config['smtp.test_server'] = '%s:%s' % (host, port)

        SmtpServerHarness.setup_class()
        CreateTestData.create()

        # make 3 changes, authored by annafan
        for i in range(3):
            pkg = model.Package.by_name(u'annakarenina')
            pkg.notes = u'Changed notes %i' % i
            model.repo.commit_and_remove()

        CreateTestData.create_user('unfinisher',
                                   about='<a href="http://unfinished.tag')
        CreateTestData.create_user('uncloser',
                                   about='<a href="http://unclosed.tag">')
        CreateTestData.create_user(
            'spammer',
            about=
            u'<a href="http://mysite">mysite</a> <a href=\u201dhttp://test2\u201d>test2</a>'
        )
        CreateTestData.create_user(
            'spammer2',
            about=
            u'<a href="http://spamsite1.com\u201d>spamsite1</a>\r\n<a href="http://www.spamsite2.com\u201d>spamsite2</a>\r\n'
        )
Example #7
0
 def initial_data(self, clean_db, clean_index):
     init_data = [
         {
             "name": "a",
             "extras": {
                 "department": "abc",
                 "agency": "ag-a"
             }
         },
         {
             "name": "b",
             "extras": {
                 "department": "bcd",
                 "agency": "ag-b"
             }
         },
         {
             "name": "c",
             "extras": {
                 "department": "cde abc"
             }
         },
         {
             "name": "none",
             "extras": {
                 "department": ""
             }
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Example #8
0
 def test_perform_reset_user_password_link_key_incorrect(self):
     CreateTestData.create_user(name='jack', password='******')
     # Make up a key - i.e. trying to hack this
     user = model.User.by_name(u'jack')
     offset = url_for(controller='user',
                      action='perform_reset',
                      id=user.id,
                      key='randomness') # i.e. incorrect
     res = self.app.get(offset, status=403) # error
Example #9
0
def test_perform_reset_user_password_link_key_incorrect(app):
    CreateTestData.create_user(name="jack", password="******")
    # Make up a key - i.e. trying to hack this
    user = model.User.by_name(u"jack")
    offset = url_for(controller="user",
                     action="perform_reset",
                     id=user.id,
                     key="randomness")  # i.e. incorrect
    res = app.get(offset, status=403)  # error
Example #10
0
 def setup_class(self, clean_db, clean_index):
     CreateTestData.create_search_test_data()
     # now remove a tag so we can test search with deleted tags
     gils = model.Package.by_name(u"gils")
     # an existing tag used only by gils
     self.tagname = u"registry"
     idx = [t.name for t in gils.get_tags()].index(self.tagname)
     gils.remove_tag(gils.get_tags()[idx])
     model.repo.commit_and_remove()
Example #11
0
 def setup_class(cls):
     CreateTestData.create()
     cls.app = paste.fixture.TestApp(pylons.test.pylonsapp)
     joeadmin = ckan.model.User.get("joeadmin")
     cls.joeadmin = {"id": joeadmin.id, "apikey": joeadmin.apikey}
     annafan = ckan.model.User.get("annafan")
     cls.annafan = {"id": annafan.id, "apikey": annafan.apikey}
     testsysadmin = ckan.model.User.get("testsysadmin")
     cls.testsysadmin = {"id": testsysadmin.id, "apikey": testsysadmin.apikey}
     cls.new_user = cls.user_create()
Example #12
0
def test_index(app):
    CreateTestData.create()
    url = url_for("admin.index")
    response = app.get(url, status=403)
    # random username
    response = app.get(url,
                       status=403,
                       extra_environ={"REMOTE_USER": "******"})
    # now test real access
    username = u"testsysadmin".encode("utf8")
    response = app.get(url, extra_environ={"REMOTE_USER": username})
    assert "Administration" in response, response
Example #13
0
 def setup_class(cls):
     model.Session.remove()
     setup_test_search_index()
     CreateTestData.create_search_test_data()
     # now remove a tag so we can test search with deleted tags
     model.repo.new_revision()
     gils = model.Package.by_name(u'gils')
     # an existing tag used only by gils
     cls.tagname = u'registry'
     idx = [t.name for t in gils.get_tags()].index(cls.tagname)
     gils.remove_tag(gils.get_tags()[idx])
     model.repo.commit_and_remove()
 def setup_class(cls):
     model.Session.remove()
     setup_test_search_index()
     CreateTestData.create_search_test_data()
     # now remove a tag so we can test search with deleted tags
     model.repo.new_revision()
     gils = model.Package.by_name(u'gils')
     # an existing tag used only by gils
     cls.tagname = u'registry'
     idx = [t.name for t in gils.get_tags()].index(cls.tagname)
     gils.remove_tag(gils.get_tags()[idx])
     model.repo.commit_and_remove()
 def setup_class(cls):
     CreateTestData.create()
     cls.app = paste.fixture.TestApp(pylons.test.pylonsapp)
     joeadmin = ckan.model.User.get('joeadmin')
     cls.joeadmin = {'id': joeadmin.id, 'apikey': joeadmin.apikey}
     annafan = ckan.model.User.get('annafan')
     cls.annafan = {'id': annafan.id, 'apikey': annafan.apikey}
     testsysadmin = ckan.model.User.get('testsysadmin')
     cls.testsysadmin = {
         'id': testsysadmin.id,
         'apikey': testsysadmin.apikey
     }
     cls.new_user = cls.user_create()
Example #16
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [{'name':u'test1-penguin-canary',
                   'title':u'penguin',
                   'tags':u'canary goose squirrel wombat wombat'.split()},
                  {'name':u'test2-squirrel-squirrel-canary-goose',
                   'title':u'squirrel goose',
                   'tags':u'penguin wombat'.split()},
                  ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [
         u'test1-penguin-canary',
         u'test2-squirrel-squirrel-canary-goose'
     ]
Example #17
0
    def setup_class(cls):
        cls._original_config = config.copy()
        for key in config.keys():
            if key.startswith('ofs'):
                del config[key]
        config['ofs.impl'] = 'pairtree'
        config['ckan.storage.bucket'] = 'ckantest'
        config['ofs.storage_dir'] = '/tmp/ckan-test-ckanext-storage'

        create_pairtree_marker( config['ofs.storage_dir'] )
        wsgiapp = make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)

        CreateTestData.create_test_user()
Example #18
0
 def setup_class(cls):
     ckan.model.repo.rebuild_db()
     ckan.lib.search.clear_all()
     CreateTestData.create()
     cls.app = helpers._get_test_app()
     joeadmin = ckan.model.User.get('joeadmin')
     cls.joeadmin = {'id': joeadmin.id, 'apikey': joeadmin.apikey}
     annafan = ckan.model.User.get('annafan')
     cls.annafan = {'id': annafan.id, 'apikey': annafan.apikey}
     testsysadmin = ckan.model.User.get('testsysadmin')
     cls.testsysadmin = {
         'id': testsysadmin.id,
         'apikey': testsysadmin.apikey
     }
     cls.new_user = cls.user_create()
Example #19
0
 def initial_data(self, clean_db):
     CreateTestData.create()
     notes = 'A <b>great</b> package <script href="dodgy.js"/> like package:pollution_stats'
     pkgs = (
         model.Session.query(model.Package).filter_by(name=self.name).all()
     )
     for p in pkgs:
         p.purge()
     model.Session.commit()
     pkg1 = model.Package(name=self.name)
     model.Session.add(pkg1)
     pkg1.notes = notes
     pkg1.license_id = u"odc-by"
     model.Session.commit()
     model.Session.remove()
Example #20
0
 def setup_class(cls):
     cls._original_config = config.copy()
     for key in config.keys():
         if key.startswith('ofs'):
             del config[key]
     config['ckan.storage.bucket'] = 'ckantest'
     config['ofs.impl'] = 'pairtree'
     config['ofs.storage_dir'] = '/tmp/ckan-test-ckanext-storage'
     create_pairtree_marker( config['ofs.storage_dir'] )
     wsgiapp = make_app(config['global_conf'], **config)
     cls.app = paste.fixture.TestApp(wsgiapp)
     CreateTestData.create()
     model.Session.remove()
     user = model.User.by_name('tester')
     cls.extra_environ = {'Authorization': str(user.apikey)}
Example #21
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {'name':'eng',
          'extras':{'geographic_coverage':'100000: England'},},
         {'name':'eng_ni',
          'extras':{'geographic_coverage':'100100: England, Northern Ireland'},},
         {'name':'uk',
          'extras':{'geographic_coverage':'111100: United Kingdom (England, Scotland, Wales, Northern Ireland'},},
         {'name':'gb',
          'extras':{'geographic_coverage':'111000: Great Britain (England, Scotland, Wales)'},},
         {'name':'none',
          'extras':{'geographic_coverage':'000000:'},},
     ]
     CreateTestData.create_arbitrary(init_data)
Example #22
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {'name':'a',
          'extras':{'department':'abc',
                    'agency':'ag-a'},},
         {'name':'b',
          'extras':{'department':'bcd',
                    'agency':'ag-b'},},
         {'name':'c',
          'extras':{'department':'cde abc'},},
         {'name':'none',
          'extras':{'department':''},},
         ]
     CreateTestData.create_arbitrary(init_data)
    def setup_class(self, clean_db, clean_index):
        # Force a garbage collection to trigger issue #695
        import gc

        gc.collect()

        CreateTestData.create()

        new_pkg_dict = {
            "name": "council-owned-litter-bins",
            "notes": "Location of Council owned litter bins within Borough.",
            "resources": [
                {
                    "description": "Resource locator",
                    "format": "Unverified",
                    "url": "http://www.barrowbc.gov.uk",
                }
            ],
            "tags": ["Utility and governmental services"],
            "title": "Council Owned Litter Bins",
            "extras": {
                "INSPIRE": "True",
                "bbox-east-long": "-3.12442",
                "bbox-north-lat": "54.218407",
                "bbox-south-lat": "54.039634",
                "bbox-west-long": "-3.32485",
                "constraint": "conditions unknown; (e) intellectual property rights;",
                "dataset-reference-date": json.dumps(
                    [
                        {"type": "creation", "value": "2008-10-10"},
                        {"type": "revision", "value": "2009-10-08"},
                    ]
                ),
                "guid": "00a743bf-cca4-4c19-a8e5-e64f7edbcadd",
                "metadata-date": "2009-10-16",
                "metadata-language": "eng",
                "published_by": 0,
                "resource-type": "dataset",
                "spatial-reference-system": "test-spatial",
                "temporal_coverage-from": "1977-03-10T11:45:30",
                "temporal_coverage-to": "2005-01-15T09:10:00",
            },
        }

        CreateTestData.create_arbitrary(new_pkg_dict)
Example #24
0
    def initial_data(self, clean_db):
        CreateTestData.create()

        # tag whose association will get deleted
        tag3 = model.Tag(name=self.tagname)
        pkg = model.Package.by_name(u"annakarenina")
        pkg.add_tag(tag3)
        model.repo.commit_and_remove()

        pkg = model.Package.by_name(u"annakarenina")
        pkg.remove_tag(tag3)
        # now do a tag for ordering
        tagordered = model.Tag(name=self.orderedfirst)
        wap = model.Package.by_name(u"warandpeace")
        # do them the wrong way round
        wap.add_tag(tagordered)
        pkg.add_tag(tagordered)
        model.repo.commit_and_remove()
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': u'test1-penguin-canary',
             'title': u'penguin',
             'tags': u'canary goose squirrel wombat wombat'.split()
         },
         {
             'name': u'test2-squirrel-squirrel-canary-goose',
             'title': u'squirrel goose',
             'tags': u'penguin wombat'.split()
         },
     ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [
         u'test1-penguin-canary', u'test2-squirrel-squirrel-canary-goose'
     ]
Example #26
0
 def setup_class(cls):
     CreateTestData.create()
     cls.app = paste.fixture.TestApp(pylons.test.pylonsapp)
     joeadmin = ckan.model.User.get('joeadmin')
     cls.joeadmin = {
             'id': joeadmin.id,
             'apikey': joeadmin.apikey
             }
     annafan = ckan.model.User.get('annafan')
     cls.annafan = {
             'id': annafan.id,
             'apikey': annafan.apikey
             }
     testsysadmin = ckan.model.User.get('testsysadmin')
     cls.testsysadmin = {
             'id': testsysadmin.id,
             'apikey': testsysadmin.apikey
             }
     cls.new_user = cls.user_create()
Example #27
0
def test_user_delete_redirects_to_user_index(app):
    user = CreateTestData.create_user("a_user")
    url = url_for("user.delete", id=user.id)
    extra_environ = {"REMOTE_USER": "******"}

    redirect_url = url_for("user.index", qualified=True)
    res = app.post(url, extra_environ=extra_environ, follow_redirects=False)

    assert user.is_deleted(), user
    assert res.headers["Location"].startswith(redirect_url)
Example #28
0
 def initial_data(self, clean_db, clean_index):
     setup_test_search_index()
     init_data = [
         {
             "name": u"test1-penguin-canary",
             "title": u"penguin",
             "tags": u"canary goose squirrel wombat wombat".split(),
         },
         {
             "name": u"test2-squirrel-squirrel-canary-goose",
             "title": u"squirrel goose",
             "tags": u"penguin wombat".split(),
         },
     ]
     CreateTestData.create_arbitrary(init_data)
     self.pkg_names = [
         u"test1-penguin-canary",
         u"test2-squirrel-squirrel-canary-goose",
     ]
Example #29
0
 def setup_class(cls):
     cls._original_config = config.copy()
     config['ckan.storage.bucket'] = 'ckantest'
     config['ofs.impl'] = 'google'
     if 'ofs.gs_secret_access_key' not in config:
         raise Exception('You will need to configure access to google storage to run this test')
     # You will need these configured in your
     # config['ofs.gs_access_key_id'] = 'GOOGCABCDASDASD'
     # config['ofs.gs_secret_access_key'] = '134zsdfjkw4234addad'
     # need to ensure not configured for local as breaks google setup
     # (and cannot delete all ofs keys as need the gs access codes)
     if 'ofs.storage_dir' in config:
         del config['ofs.storage_dir']
     wsgiapp = make_app(config['global_conf'], **config)
     cls.app = paste.fixture.TestApp(wsgiapp)
     # setup test data including testsysadmin user
     CreateTestData.create()
     model.Session.remove()
     user = model.User.by_name('tester')
     cls.extra_environ = {'Authorization': str(user.apikey)}
Example #30
0
    def test_user_delete_redirects_to_user_index(self):
        user = CreateTestData.create_user('a_user')
        url = url_for(controller='user', action='delete', id=user.id)
        extra_environ = {'REMOTE_USER': '******'}

        redirect_url = url_for(controller='user', action='index',
                qualified=True)
        res = self.app.get(url, status=302, extra_environ=extra_environ)

        assert user.is_deleted(), user
        assert res.header('Location').startswith(redirect_url), res.header('Location')
Example #31
0
 def setup_class(cls):
     ckan.model.repo.rebuild_db()
     ckan.lib.search.clear_all()
     CreateTestData.create()
     cls.app = helpers._get_test_app()
     joeadmin = ckan.model.User.get('joeadmin')
     cls.joeadmin = {
             'id': joeadmin.id,
             'apikey': joeadmin.apikey
             }
     annafan = ckan.model.User.get('annafan')
     cls.annafan = {
             'id': annafan.id,
             'apikey': annafan.apikey
             }
     testsysadmin = ckan.model.User.get('testsysadmin')
     cls.testsysadmin = {
             'id': testsysadmin.id,
             'apikey': testsysadmin.apikey
             }
     cls.new_user = cls.user_create()
Example #32
0
    def setup_class(cls):
        smtp_server = config.get('smtp.test_server')
        if smtp_server:
            host, port = smtp_server.split(':')
            port = int(port) + int(str(hashlib.md5(cls.__name__).hexdigest())[0], 16)
            config['smtp.test_server'] = '%s:%s' % (host, port)

        SmtpServerHarness.setup_class()
        CreateTestData.create()

        # make 3 changes, authored by annafan
        for i in range(3):
            rev = model.repo.new_revision()
            pkg = model.Package.by_name(u'annakarenina')
            pkg.notes = u'Changed notes %i' % i
            rev.author = u'annafan'
            model.repo.commit_and_remove()

        CreateTestData.create_user('unfinisher', about='<a href="http://unfinished.tag')
        CreateTestData.create_user('uncloser', about='<a href="http://unclosed.tag">')
        CreateTestData.create_user('spammer', about=u'<a href="http://mysite">mysite</a> <a href=\u201dhttp://test2\u201d>test2</a>')
        CreateTestData.create_user('spammer2', about=u'<a href="http://spamsite1.com\u201d>spamsite1</a>\r\n<a href="http://www.spamsite2.com\u201d>spamsite2</a>\r\n')
Example #33
0
 def initial_data(self, clean_db, clean_index):
     CreateTestData.create()
     self.package_fixture_data = {
         "name": u"testpkg",
         "title": "Some Title",
         "url": u"http://blahblahblah.mydomain",
         "resources": [
             {
                 u"url": u"http://blahblahblah.mydomain",
                 u"format": u"",
                 u"description": "",
             }
         ],
         "tags": ["russion", "novel"],
         "license_id": u"gpl-3.0",
         "extras": {
             "national_statistic": "yes",
             "geographic_coverage": "England, Wales",
         },
     }
     CreateTestData.create_arbitrary(self.package_fixture_data)
     self.base_url = self.offset("/action/package_search")
    def setup_class(cls):
        setup_test_search_index()
        # Force a garbage collection to trigger issue #695
        import gc
        gc.collect()

        CreateTestData.create()

        cls.new_pkg_dict = {
            'name': 'council-owned-litter-bins',
            'notes': 'Location of Council owned litter bins within Borough.',
            'resources': [{'description': 'Resource locator',
                           'format': 'Unverified',
                           'url': 'http://www.barrowbc.gov.uk'}],
            'tags': ['Utility and governmental services'],
            'title': 'Council Owned Litter Bins',
            'extras': {
                'INSPIRE': 'True',
                'bbox-east-long': '-3.12442',
                'bbox-north-lat': '54.218407',
                'bbox-south-lat': '54.039634',
                'bbox-west-long': '-3.32485',
                'constraint': 'conditions unknown; (e) intellectual property rights;',
                'dataset-reference-date': json.dumps(
                                          [{'type': 'creation',
                                            'value': '2008-10-10'},
                                           {'type': 'revision',
                                            'value': '2009-10-08'}]),
                'guid': '00a743bf-cca4-4c19-a8e5-e64f7edbcadd',
                'metadata-date': '2009-10-16',
                'metadata-language': 'eng',
                'published_by': 0,
                'resource-type': 'dataset',
                'spatial-reference-system': 'test-spatial',
                'temporal_coverage-from': '1977-03-10T11:45:30',
                'temporal_coverage-to': '2005-01-15T09:10:00'
            }
        }
Example #35
0
    def setup_class(self):
        model.Session.remove()
        CreateTestData.create()
        self.name = u'revisiontest'

        # create pkg
        self.descriptions = [u'Written by Puccini', u'Written by Rossini', u'Not written at all', u'Written again', u'Written off']
        rev = model.repo.new_revision()
        self.grp = model.Group(name=self.name)
        model.Session.add(self.grp)
        self.grp.description = self.descriptions[0]
        self.grp.extras['mykey'] = self.descriptions[0]
        model.repo.commit_and_remove()

        # edit pkg
        for i in range(5)[1:]:
            rev = model.repo.new_revision()
            grp = model.Group.by_name(self.name)
            grp.description = self.descriptions[i]
            grp.extras['mykey'] = self.descriptions[i]
            model.repo.commit_and_remove()

        self.grp = model.Group.by_name(self.name)        
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': 'eng',
             'extras': {
                 'geographic_coverage': '100000: England'
             },
         },
         {
             'name': 'eng_ni',
             'extras': {
                 'geographic_coverage': '100100: England, Northern Ireland'
             },
         },
         {
             'name': 'uk',
             'extras': {
                 'geographic_coverage':
                 '111100: United Kingdom (England, Scotland, Wales, Northern Ireland'
             },
         },
         {
             'name': 'gb',
             'extras': {
                 'geographic_coverage':
                 '111000: Great Britain (England, Scotland, Wales)'
             },
         },
         {
             'name': 'none',
             'extras': {
                 'geographic_coverage': '000000:'
             },
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Example #37
0
 def setup_class(self, clean_db, clean_index):
     init_data = [
         {
             "name": "eng",
             "extras": {
                 "geographic_coverage": "100000: England"
             },
         },
         {
             "name": "eng_ni",
             "extras": {
                 "geographic_coverage": "100100: England, Northern Ireland"
             },
         },
         {
             "name": "uk",
             "extras": {
                 "geographic_coverage":
                 "111100: United Kingdom (England, Scotland, Wales, Northern Ireland"
             },
         },
         {
             "name": "gb",
             "extras": {
                 "geographic_coverage":
                 "111000: Great Britain (England, Scotland, Wales)"
             },
         },
         {
             "name": "none",
             "extras": {
                 "geographic_coverage": "000000:"
             }
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Example #38
0
    def test_perform_reset_doesnt_activate_deleted_user(self):
        password = '******'
        params = { 'password1': password, 'password2': password }
        user = CreateTestData.create_user(name='deleted_user',
                                          email='*****@*****.**')
        user.delete()
        create_reset_key(user)
        assert user.is_deleted(), user.state

        offset = url_for(controller='user',
                         action='perform_reset',
                         id=user.id,
                         key=user.reset_key)
        res = self.app.post(offset, params=params, status=403)

        user = model.User.get(user.id)
        assert user.is_deleted(), user
Example #39
0
    def test_perform_reset_activates_pending_user(self):
        password = '******'
        params = { 'password1': password, 'password2': password }
        user = CreateTestData.create_user(name='pending_user',
                                          email='*****@*****.**')
        user.set_pending()
        create_reset_key(user)
        assert user.is_pending(), user.state


        with self.app.flask_app.test_request_context():
            offset = url_for(controller='user',
                         action='perform_reset',
                         id=user.id,
                         key=user.reset_key)
        res = self.app.post(offset, params=params, status=302)

        user = model.User.get(user.id)
        assert user.is_active(), user
Example #40
0
def test_perform_reset_doesnt_activate_deleted_user(app):
    password = "******"
    params = {"password1": password, "password2": password}
    user = CreateTestData.create_user(name="deleted_user",
                                      email="*****@*****.**")
    user.delete()
    create_reset_key(user)
    assert user.is_deleted(), user.state

    offset = url_for(
        controller="user",
        action="perform_reset",
        id=user.id,
        key=user.reset_key,
    )
    res = app.post(offset, params=params, status=403)

    user = model.User.get(user.id)
    assert user.is_deleted(), user
Example #41
0
 def setup_class(self):
     CreateTestData.create_group_hierarchy_test_data()
Example #42
0
 def setup_class(cls):
     setup_test_search_index()
     CreateTestData.create()
Example #43
0
 def setup_class(self):
     model.repo.rebuild_db()
     CreateTestData.create()
Example #44
0
 def setup_class(self):
     CreateTestData.create()
     model.Session.remove()
Example #45
0
 def setup(cls):
     if not asbool(config.get('ckan.activity_streams_enabled', 'true')):
         raise SkipTest('Activity streams not enabled')
     CreateTestData.create()
     cls.sysadmin_user = ckan.model.User.get('testsysadmin')
     cls.app = helpers._get_test_app()
Example #46
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
     CreateTestData.delete()
 def _create_package(self, package=None):
     CreateTestData.create_arbitrary(self.new_pkg_dict)
     return model.Package.by_name(self.new_pkg_dict['name'])
Example #48
0
 def setup(cls):
     if not asbool(config.get('ckan.activity_streams_enabled', 'true')):
         raise SkipTest('Activity streams not enabled')
     CreateTestData.create()
     cls.sysadmin_user = ckan.model.User.get('testsysadmin')
     cls.app = paste.fixture.TestApp(pylonsapp)
Example #49
0
 def setup_class(cls):
     # setup test data including testsysadmin user
     CreateTestData.create()
Example #50
0
 def setup_class(self):
     model.Session.remove()
     # rebuild db before this test as it depends delicately on what
     # revisions exist
     model.repo.init_db()
     CreateTestData.create()
Example #51
0
 def setup_class(cls):
     setup_test_search_index()
     CreateTestData.create_search_test_data()
     cls.solr = search.make_connection()
     cls.fq = " +site_id:\"%s\" " % config['ckan.site_id']
     search.rebuild()
Example #52
0
 def setup_class(cls):
     # setup test data including testsysadmin user
     CreateTestData.create()
     model.Session.commit()