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


Python Project.get_id方法代码示例

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


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

示例1: test_update

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [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: setup_user_project_list

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def setup_user_project_list():
    user = User()
    user.create('test_user_list','test_pass','[email protected]')
    project = Project()
    project.create('project list 1','project content 1')
    user.add_project(project.get_id())
    project = Project()
    project.create('project list 2','project content 2')
    user.add_project(project.get_id())
    project = Project()
    project.create('project list 3','project content 3')
    user.add_project(project.get_id())
开发者ID:sweemeng,项目名称:scrapedump,代码行数:14,代码来源:test_project_api.py

示例3: setup_user

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def setup_user():
    user = User()
    user.create('test_user','test_pass','[email protected]')
    project = Project()
    project.create('scraped','scraped')
    project.add_entry('entry','entry','localhost')
    user.add_project(project.get_id())
开发者ID:sweemeng,项目名称:scrapedump,代码行数:9,代码来源:test_api.py

示例4: setup_project_update

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def setup_project_update():
    user = User()
    user.create('test_update_user','test_password','[email protected]')
    project = Project()
    project.create('project update','test project update')
    user.add_project(project.get_id())
    project.add_entry('data','test data','data')
开发者ID:sweemeng,项目名称:scrapedump,代码行数:9,代码来源:test_project_frontend.py

示例5: setup_test_update

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def setup_test_update():
    mongo = MongoModel(project='test_api_update',collection='test_api_entry')
    mongo.insert({'a':1})
    user = User()
    user.create('test_user_api_update','test_pass','[email protected]')
    project = Project()
    project.create('test api update','scraped')
    project.add_entry('test api entry','entry','localhost')
    user.add_project(project.get_id())
开发者ID:sweemeng,项目名称:scrapedump,代码行数:11,代码来源:test_api.py

示例6: setup_user_project

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def setup_user_project():
    # now create user
    user = User()
    user.create('test_user_update_project','test_pass','[email protected]') 
    # create project
    project = Project()
    project.create('project update','project update content')
    # associate project
    user.add_project(project.get_id())
开发者ID:sweemeng,项目名称:scrapedump,代码行数:11,代码来源:test_project_api.py

示例7: test_user_project_withdraw

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def test_user_project_withdraw():
    user = User()
    user.login('test_user_list','test_pass') 
    project = Project()
    project.find('project list 3')

    user.add_project(project.get_id())
    api_key = user.user.auth_token
    test_client = webapp.app.test_client()

    url = '/api/project/%s/?api_key=%s' % (project.get_id(),api_key)
       
    data = {'project':'project_list_3','action':'withdraw'}

    result = test_client.put(url,data=json.dumps(data),content_type='application/json')
    print result.data 
    user.login('test_user_list','test_pass')
    print user.user.project
    print project.get_id()
    print project.project.name
    assert not str(project.get_id()) in user.user.project
开发者ID:sweemeng,项目名称:scrapedump,代码行数:23,代码来源:test_project_api.py

示例8: test_project_delete

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def test_project_delete():
    # login user get token
    user = User()
    user.login('test_user_delete_api_project','test_pass')
    
    api_key = user.user.auth_token
    print api_key
    project = Project()
    project.find('project 1')
    project_id = project.get_id()
    # do a delete
    test_client = webapp.app.test_client()
    url = '/api/project/%s/?api_key=%s' % (project.project.id,api_key)
    result = test_client.delete(url)
    status = json.loads(result.data)
    # now check user don't exist
    project = Project()
    model = MongoModel(project=project.project_,collection=project.collection_)
    data = model.query({'name':'project 1'})
    assert not data

    test_user = User()
    test_user.login('test_user_delete','test_pass')
    assert project_id not in test_user.user.project
开发者ID:sweemeng,项目名称:scrapedump,代码行数:26,代码来源:test_project_api.py

示例9: setup_project_delete

# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_id [as 别名]
def setup_project_delete():
    user = User()
    user.create('test_user_delete_api_project','test_pass','[email protected]')
    project = Project()
    project.create('project 1','project content 1')
    user.add_project(project.get_id())
开发者ID:sweemeng,项目名称:scrapedump,代码行数:8,代码来源:test_project_api.py


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