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


Python Project.find_entry方法代码示例

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


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

示例1: test_update

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_update():
    user = User()
    user.login('test_user_api_update','test_pass')
    api_key = user.user.auth_token

    project = Project()
    project.find('test api update')
    entry_id = project.find_entry('test api entry')
    print user.get_project()
    print project.get_id()
    mongo = MongoModel(project='test_api_update',collection='test_api_entry')
    data = mongo.query({'a':1})
    print data
    id = str(data['_id'])
    updated = {'a':2}
    url = '/api/db/%s/%s/%s/?api_key=%s' % (project.project.id,entry_id,id,api_key) 
    
    client = webapp.app.test_client()
    response = client.put(url, data = json.dumps(updated),
            content_type='application/json')
    print response.data
    status = json.loads(response.data)
    
    assert status['status']
  
    updated_data = mongo.query({'_id':objectid.ObjectId(id)})
    assert updated_data['a'] == 2
开发者ID:sweemeng,项目名称:scrapedump,代码行数:29,代码来源:test_api.py

示例2: test_get_all

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_get_all():
    project = Project()
    project.find('scraped')
    entry_id = project.find_entry('entry')
    client = webapp.app.test_client()
    response = client.get('/api/db/%s/%s/' % (project.project.id,entry_id))
    result = json.loads(response.data)
    
    assert result[0]['a'] == 1
开发者ID:sweemeng,项目名称:scrapedump,代码行数:11,代码来源:test_api.py

示例3: test_project_stats

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_project_stats():
    project = Project()
    project.find('test project db')
    entry_id = project.find_entry('test entries')
    print entry_id
    print project.project.entry
    databases = project.get_stats()
    for database in databases:
        assert database == entry_id 
开发者ID:sweemeng,项目名称:scrapedump,代码行数:11,代码来源:test_project.py

示例4: test_load_data

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_load_data():
    project = Project()
    project.find('test load data')
    entry_id = project.find_entry('test entries')
    datasource = project.project.input_file[entry_id]
    key = datasource.keys()[0]
    entry = project.get_entry_collection(entry_id)
    print key
    project.load_datafile(entry_id,key)
    test_data = entry.query({'a':'1'})
    assert test_data['b'] == '2' 
    assert test_data['c'] == '3'
开发者ID:sweemeng,项目名称:scrapedump,代码行数:14,代码来源:test_project.py

示例5: test_get

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_get():
    mongo = MongoModel(project='scraped',collection='entry')
    client = webapp.app.test_client()

    data = mongo.all()

    id = str(data[0]['_id'])
    project = Project()
    project.find('scraped')
    entry_id = project.find_entry('entry')
    response = client.get('/api/db/%s/%s/%s/' % (project.project.id,entry_id,id))
    result = json.loads(response.data)

    assert result['a'] == 1
开发者ID:sweemeng,项目名称:scrapedump,代码行数:16,代码来源:test_api.py

示例6: test_project_file_download

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_project_file_download():
    content = "a,b,c\n1,2,3\n4,5,6"
    project = Project()
    project.find('test project download')
    data = project.project.input_file
    entry_id = project.find_entry('test entries')
    files = data[entry_id]
    valid_flag = False
    for file_id in files:
        test_file = project.get_datafile(file_id)
        test_data = test_file.read()
        if test_data == content:
            valid_flag = True
    
    assert valid_flag
开发者ID:sweemeng,项目名称:scrapedump,代码行数:17,代码来源:test_project.py

示例7: test_project_file_upload

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_project_file_upload():
    content = "a,b,c\n1,2,3\n4,5,6"
    test_data = cStringIO.StringIO(content)
    f = MockFile('test_data.csv',content)
    project = Project()
    project.find('test project upload')
    entry_id = project.find_entry('test entries')
    project.add_datafile(entry_id,f)
    
    input_file = project.project.input_file
    exist_flag = False
    for entry in input_file:
        for file_id in input_file[entry]:
            if input_file[entry][file_id]['filename'] == 'test_data.csv':
                exist_flag = True
    
    assert exist_flag 
开发者ID:sweemeng,项目名称:scrapedump,代码行数:19,代码来源:test_project.py

示例8: test_insert

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_insert():
    user = User()
    user.login('test_user','test_pass')
    api_key = user.user.auth_token
    client = webapp.app.test_client()
    data = {'a':1}
    project = Project()
    project.find('scraped')
    entry_id = project.find_entry('entry')
    url = '/api/db/%s/%s/?api_key=%s' % (project.project.id,entry_id,api_key)
    response = client.post(url,data=json.dumps(data),
            content_type='application/json')
    
    status = json.loads(response.data)
    assert status['status']

    mongo = MongoModel(project='scraped',collection='entry')
    check = mongo.all()
    assert check[0]['a'] == 1

    mongo.delete(check[0])
开发者ID:sweemeng,项目名称:scrapedump,代码行数:23,代码来源:test_api.py

示例9: test_delete

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find_entry [as 别名]
def test_delete():
    user = User()
    user.login('test_user','test_pass')
    api_key = user.user.auth_token
    mongo = MongoModel(project='scraped',collection='entry')
    client = webapp.app.test_client()

    mongo.insert({'a':1})
    
    data = mongo.query({'a':1})
    id = str(data['_id'])
    project = Project()
    project.find('scraped')
    entry_id = project.find_entry('entry')
    url = '/api/db/%s/%s/%s/?api_key=%s' % (project.project.id,entry_id,id,api_key) 
    response = client.delete(url)

    status = json.loads(response.data)
    assert status['status']
    
    check = mongo.query({'_id':objectid.ObjectId(id)})
    assert not check
开发者ID:sweemeng,项目名称:scrapedump,代码行数:24,代码来源:test_api.py


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