當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。