예제 #1
0
    def setup_class(cls):
        lib.create_test_data.CreateTestData.create('publisher')
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.dset = model.Package.get('warandpeace')
        cls.geo_tags = [(u'uk', u'United Kingdom'), (u'ie', u'Ireland')]

        model.repo.new_revision()
        g = model.Group.get('david')
        g.type = 'organization'
        model.Session.add(g)
        mu = model.Member(table_id=cls.sysadmin_user.id,
                          table_name='user', group=g)
        model.Session.add(mu)
        model.Session.commit()

        # use our custom select class for this test suite
        cls.old_select = paste.fixture.Field.classes['select']
        paste.fixture.Field.classes['select'] = Select

        cls.extra_environ = {'Authorization': str(cls.sysadmin_user.apikey)}

        # create status vocab
        status = test_api.create_vocab(u'status', cls.sysadmin_user.name)
        test_api.add_tag_to_vocab(u'http://purl.org/adms/status/Completed',
                                  status['id'], cls.sysadmin_user.name)
        test_api.add_tag_to_vocab(u'http://purl.org/adms/status/Withdrawn',
                                  status['id'], cls.sysadmin_user.name)

        # create geographical coverage vocab
        geo = test_api.create_vocab(u'geographical_coverage',
                                    cls.sysadmin_user.name)
        cls.geo_vocab_id = geo['id']

        for tag in cls.geo_tags:
            test_api.add_tag_to_vocab(tag[0], cls.geo_vocab_id,
                                      cls.sysadmin_user.name)
            params = json.dumps({
                'term': tag[0],
                'term_translation': tag[1],
                'lang_code': u'en'
            })
            response = cls.app.post('/api/action/term_translation_update',
                                    params=params,
                                    extra_environ=cls.extra_environ)
            assert json.loads(response.body)['success']

        # create temporal granularity
        temporal = test_api.create_vocab(u'temporal_granularity',
                                         cls.sysadmin_user.name)
        test_api.add_tag_to_vocab(u'day', temporal['id'],
                                  cls.sysadmin_user.name)
        test_api.add_tag_to_vocab(u'month', temporal['id'],
                                  cls.sysadmin_user.name)
예제 #2
0
    def setup_class(cls):
        model.Session.remove()
        tests.setup_test_search_index()

        _create_test_data.create_arbitrary(data.ecportal_search_items)
        _create_test_data.create('publisher')

        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.sysadmin_env = {'Authorization': str(cls.sysadmin_user.apikey)}

        model.repo.new_revision()

        usr = model.User(name="ectest", apikey="ectest", password=u'ectest')
        model.Session.add(usr)
        model.Session.commit()

        g = model.Group.get('david')
        g.type = 'organization'
        model.Session.add(g)

        mu = model.Member(table_id=usr.id, table_name='user', group=g)
        model.Session.add(mu)
        model.Session.commit()

        # create status vocab
        status = test_api.create_vocab(u'status', cls.sysadmin_user.name)
        test_api.add_tag_to_vocab(u'http://purl.org/adms/status/Completed',
                                  status['id'], cls.sysadmin_user.name)

        # create geographical coverage vocab
        cls.geo_tags = [(u'uk', u'United Kingdom'), (u'ie', u'Ireland')]
        geo = test_api.create_vocab(u'geographical_coverage',
                                    cls.sysadmin_user.name)
        cls.geo_vocab_id = geo['id']

        for tag in cls.geo_tags:
            test_api.add_tag_to_vocab(tag[0], cls.geo_vocab_id,
                                      cls.sysadmin_user.name)
            params = json.dumps({
                'term': tag[0],
                'term_translation': tag[1],
                'lang_code': u'en'
            })
            response = cls.app.post('/api/action/term_translation_update',
                                    params=params,
                                    extra_environ=cls.sysadmin_env)
            assert json.loads(response.body)['success']