当前位置: 首页>>代码示例>>Python>>正文


Python Dataset.by_name方法代码示例

本文整理汇总了Python中spendb.model.Dataset.by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.by_name方法的具体用法?Python Dataset.by_name怎么用?Python Dataset.by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spendb.model.Dataset的用法示例。


在下文中一共展示了Dataset.by_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete_dataset

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_delete_dataset(self):
     name = self.cra.name
     url = url_for('datasets_api.delete', name=name)
     res = self.client.delete(url, query_string=self.auth_qs)
     assert '410' in res.status, res.status
     ds = Dataset.by_name(name)
     assert ds is None, ds
开发者ID:CivicVision,项目名称:datahub,代码行数:9,代码来源:test_dataset.py

示例2: test_delete_dataset_requires_auth

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_delete_dataset_requires_auth(self):
     name = self.cra.name
     url = url_for('datasets_api.delete', name=name)
     res = self.client.delete(url, query_string={})
     assert '403' in res.status, res.status
     ds = Dataset.by_name(name)
     assert ds is not None, ds
开发者ID:CivicVision,项目名称:datahub,代码行数:9,代码来源:test_dataset.py

示例3: test_view_fields_empty

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_view_fields_empty(self):
     cra = Dataset.by_name('cra')
     cra.fields = {}
     db.session.commit()
     url = url_for('datasets_api.structure', name='cra')
     res = self.client.get(url)
     fields = res.json.get('fields')
     assert 'cap_or_cur' not in fields, res.json
开发者ID:CivicVision,项目名称:datahub,代码行数:10,代码来源:test_dataset.py

示例4: test_publish

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_publish(self):
     cra = Dataset.by_name('cra')
     cra.private = True
     db.session.commit()
     url = url_for('datasets_api.view', name='cra')
     res = self.client.get(url)
     assert '403' in res.status, res.status
     res = self.client.get(url, query_string={'api_key': self.user.api_key})
     assert '200' in res.status, res.status
     data = res.json.copy()
     data['category'] = 'budget'
     data['private'] = False
     response = self.client.post(url, data=json.dumps(data),
                                 headers={'content-type': 'application/json'},
                                 query_string={'api_key': self.user.api_key})
     assert '200' in response.status, response.json
     cra = Dataset.by_name('cra')
     assert cra.private is False, cra.private
开发者ID:CivicVision,项目名称:datahub,代码行数:20,代码来源:test_dataset.py

示例5: load_from_url

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
def load_from_url(dataset_name, url):
    with flask_app.app_context():
        dataset = Dataset.by_name(dataset_name)
        if dataset is None:
            log.error("Dataset not found: %s", dataset_name)
            return
        source = tasks.extract_url(dataset, url)
        if source is not None:
            load_from_source.delay(dataset_name, source.name)
开发者ID:annafralberts,项目名称:spendb,代码行数:11,代码来源:tasks.py

示例6: load_from_source

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
def load_from_source(dataset_name, source_name):
    with flask_app.app_context():
        dataset = Dataset.by_name(dataset_name)
        if source_name is None:
            return
        artifact = tasks.transform_source(dataset, source_name)
        if artifact is None:
            return
        tasks.load(dataset, source_name=source_name)
开发者ID:gitter-badger,项目名称:spendb,代码行数:11,代码来源:tasks.py

示例7: authz

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
def authz():
    obj = Dataset.by_name(request.args.get('dataset'))
    etag_cache_keygen(obj, private=True)
    if obj is None:
        return jsonify({
            'read': False,
            'update': False
        })
    return jsonify({
        'read': dataset.read(obj),
        'update': dataset.update(obj)
    })
开发者ID:CivicVision,项目名称:datahub,代码行数:14,代码来源:session.py

示例8: test_update_invalid_label

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_update_invalid_label(self):
     data = {'name': 'cra', 'label': '',
             'description': 'I\'m a banana',
             'currency': 'GBP'}
     res = self.client.post(url_for('datasets_api.update', name='cra'),
                            data=json.dumps(data),
                            headers={'content-type': 'application/json'},
                            query_string={'api_key': self.user.api_key})
     assert '400' in res.status, res.status
     assert 'Shorter than' in res.data, res.json
     cra = Dataset.by_name('cra')
     assert cra.label != '', cra.label
开发者ID:CivicVision,项目名称:datahub,代码行数:14,代码来源:test_dataset.py

示例9: create

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
def create():
    require.dataset.create()
    dataset = request_data()
    data = validate_dataset(dataset)
    if Dataset.by_name(data['name']) is not None:
        raise Invalid(SchemaNode(String(), name='name'),
                      _("A dataset with this identifer already exists!"))
    dataset = Dataset({'dataset': data, 'model': {}})
    dataset.managers.append(current_user)
    db.session.add(dataset)
    db.session.commit()
    return view(dataset.name)
开发者ID:annafralberts,项目名称:spendb,代码行数:14,代码来源:dataset.py

示例10: test_update

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_update(self):
     data = {'name': 'cra', 'label': 'Common Rough Act',
             'description': 'I\'m a banana',
             'currency': 'EUR', 'languages': ['en'],
             'territories': ['GB'],
             'category': 'budget'}
     res = self.client.post(url_for('datasets_api.update', name='cra'),
                            data=json.dumps(data),
                            headers={'content-type': 'application/json'},
                            query_string={'api_key': self.user.api_key})
     cra = Dataset.by_name('cra')
     assert cra.label == 'Common Rough Act', (cra.label, res.json)
     assert cra.currency == 'EUR', (cra.currency, res.json)
开发者ID:CivicVision,项目名称:datahub,代码行数:15,代码来源:test_dataset.py

示例11: test_update_invalid_territory

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_update_invalid_territory(self):
     data = {'name': 'cra', 'label': 'CRA',
             'territories': ['su'],
             'description': 'I\'m a banana',
             'currency': 'GBP'}
     response = self.client.post(url_for('datasets_api.update', name='cra'),
                                 data=json.dumps(data),
                                 headers={'content-type': 'application/json'},
                                 query_string={'api_key': self.user.api_key})
     assert '400' in response.status, response.status
     assert 'updated' not in response.data
     cra = Dataset.by_name('cra')
     assert 'su' not in cra.territories
开发者ID:CivicVision,项目名称:datahub,代码行数:15,代码来源:test_dataset.py

示例12: test_update_invalid_currency

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_update_invalid_currency(self):
     data = {'name': 'cra',
             'label': 'Common Rough Act',
             'description': 'I\'m a banana',
             'category': 'budget',
             'currency': 'glass pearls'}
     res = self.client.post(url_for('datasets_api.update', name='cra'),
                            data=json.dumps(data),
                            headers={'content-type': 'application/json'},
                            query_string={'api_key': self.user.api_key})
     assert 'not one of' in res.data, res.json
     cra = Dataset.by_name('cra')
     assert cra.currency == 'GBP', cra.label
开发者ID:CivicVision,项目名称:datahub,代码行数:15,代码来源:test_dataset.py

示例13: get_or_create_dataset

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
def get_or_create_dataset(model):
    """ Based on a provided model we get the model (if it doesn't
    exist we create it). """
    dataset = Dataset.by_name(model['dataset']['name'])

    # If the dataset wasn't found we create it
    if dataset is None:
        dataset = Dataset(model)
        db.session.add(dataset)
        db.session.commit()

    log.info("Dataset: %s", dataset.name)
    return dataset
开发者ID:CivicVision,项目名称:datahub,代码行数:15,代码来源:importer.py

示例14: load_from_source

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
def load_from_source(dataset_name, source_name):
    with flask_app.app_context():
        dataset = Dataset.by_name(dataset_name)
        if dataset is None:
            log.error("Dataset not found: %s", dataset_name)
            return
        if source_name is None:
            log.error("No source specified: %s", dataset_name)
            return
        artifact = tasks.transform_source(dataset, source_name)
        if artifact is None:
            return
        tasks.load(dataset, source_name=source_name)
开发者ID:annafralberts,项目名称:spendb,代码行数:15,代码来源:tasks.py

示例15: test_update_invalid_category

# 需要导入模块: from spendb.model import Dataset [as 别名]
# 或者: from spendb.model.Dataset import by_name [as 别名]
 def test_update_invalid_category(self):
     data = {'name': 'cra',
             'label': 'Common Rough Act',
             'description': 'I\'m a banana',
             'currency': 'EUR', 'languages': ['en'],
             'territories': ['GB'], 'category': 'foo'}
     res = self.client.post(url_for('datasets_api.update', name='cra'),
                            data=json.dumps(data),
                            headers={'content-type': 'application/json'},
                            query_string={'api_key': self.user.api_key})
     assert '400' in res.status, res.status
     assert 'not one of' in res.data, res.json
     cra = Dataset.by_name('cra')
     assert cra.label != 'Common Rough Act', cra.label
开发者ID:CivicVision,项目名称:datahub,代码行数:16,代码来源:test_dataset.py


注:本文中的spendb.model.Dataset.by_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。