本文整理汇总了Python中project.model.Project.find方法的典型用法代码示例。如果您正苦于以下问题:Python Project.find方法的具体用法?Python Project.find怎么用?Python Project.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类project.model.Project
的用法示例。
在下文中一共展示了Project.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [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
示例2: test_project_update
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def test_project_update():
project = Project()
project.find('test project update')
project.project.description = 'project updated'
project.save()
db = MongoModel(project='internal',collection='project')
temp = db.query({'name':'test project update'})
assert temp['description'] == 'project updated'
示例3: test_project_stats
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [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
示例4: test_get_all
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [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
示例5: teardown_project_delete
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def teardown_project_delete():
user = User()
user.login('test_user_delete_api_project','test_pass')
project = Project()
model = MongoModel(project=user.project,collection=user.collection)
model.delete({'_id':ObjectId(user.user.id)})
project.find('project 1')
model = MongoModel(project=project.project_,collection=project.collection_)
model.delete({'name':'project 1'})
model.conn.drop_database('project_1')
示例6: test_project_view
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def test_project_view():
test_client = webapp.app.test_client()
result = test_client.get('/')
project = Project()
project.find('project view')
assert project.project.id in result.data
result = test_client.get('/project/%s/'% project.project.id)
assert 'project view' in result.data
assert 'data' in result.data
示例7: teardown_test_load_data
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def teardown_test_load_data():
project = Project()
project.find('test load data')
fs = gridfs.GridFS(project.get_db())
for entry in project.project.input_file:
for file_id in project.project.input_file[entry]:
fs.delete(ObjectId(file_id))
db = MongoModel(project='internal',collection='project')
db.delete({'name':'test load data'})
db.conn.drop_database('test_load_data')
示例8: teardown_project
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def teardown_project():
data = (
('project 1','project content 1'),
('project 2','project content 2'),
('project 3','project content 3')
)
for d in data:
project = Project()
project.find(d[0])
model = MongoModel(project=project.project_,collection=project.collection_)
model.delete({'_id':ObjectId(str(project.project.id))})
model.conn.drop_database(d[0].replace(' ','_'))
示例9: test_project_entries
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def test_project_entries():
project = Project()
project.find('test project entries')
# add_entries now should have a description and name file
# there should be a short name field, for field name
# We should have a source
entry_id = project.add_entry('test entries','test data','test_entries','test_entries')
db = MongoModel(project='internal',collection='project')
temp = db.query({'name':'test project entries'})
assert entry_id in temp['stats']
示例10: test_load_data
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [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'
示例11: test_get
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [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
示例12: get_entry
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def get_entry(project_id,entry):
form = EntryUpdateForm()
edit = False
# entry should be short_name
if form.validate_on_submit():
project = Project()
description = form.description.data
source = form.source.data
project.get(project_id)
project.update_entry(entry,description,source)
return redirect('/entry/%s/%s/' % (project_id,entry))
project = Project()
project.find(project_name)
return render_template('entry_view.html',project=project,entry=entry,
edit=edit,form=form)
示例13: test_project_update
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def test_project_update():
test_client = webapp.app.test_client()
result = test_client.post('/login/',data={
'username':'test_update_user',
'password':'test_password'
},follow_redirects=True)
project = Project()
project.find('project update')
project_ui = test_client.post('/project/%s/' % project.project.id,data={
'description':'project updated',
},follow_redirects=True)
print project_ui.data
assert 'project updated' in project_ui.data
assert 'data' in project_ui.data
示例14: test_project_file_download
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [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
示例15: get
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import find [as 别名]
def get(self, *args, **kwargs):
if not self.user.admin:
self.add_message(u'您没有访问该页面的权限, 请联系管理员')
return self.render('failed.html')
ps = Project.find(status__no=Project._status_del)
users = User.find(status=User._status_ok)
return self.render('manager.html', ps=ps, users=users)