本文整理汇总了Python中tests.testing.make_environ函数的典型用法代码示例。如果您正苦于以下问题:Python make_environ函数的具体用法?Python make_environ怎么用?Python make_environ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_environ函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_allowed
def test_allowed(self, app, dbsession, group):
from occams import models
environ = make_environ(userid=USERID, groups=[group])
csrf_token = get_csrf_token(app, environ)
cycle_id = dbsession.query(models.Cycle.id).filter(
models.Cycle.name == u'TestCycle').scalar()
data = {
'cycles': [cycle_id],
'visit_date': '2015-01-01',
'include_forms': False,
'include_speciman': False
}
res = app.post_json(
self.url,
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token,
'X-REQUESTED-WITH': str('XMLHttpRequest')
},
params=data)
assert 200 == res.status_code
示例2: test_not_allowed
def test_not_allowed(self, app, dbsession, group):
from occams import models
environ = make_environ(userid=USERID, groups=[group])
csrf_token = get_csrf_token(app, environ)
enrollment_id = dbsession.query(models.Enrollment.id).filter(
models.Study.name == u'test_study').scalar()
data = {
'ofmetadata_-collect_date': '2015-01-01',
'ofmetadata_-version': '2015-01-01',
'ofmetadata_-state': 'pending-entry',
}
res = app.post(
self.url.format(enrollment_id),
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token,
'X-REQUESTED-WITH': str('XMLHttpRequest')
},
xhr=True,
params=data)
assert 403 == res.status_code
示例3: test_not_allowed
def test_not_allowed(self, app, dbsession, group):
from occams import models
environ = make_environ(userid=USERID, groups=[group])
csrf_token = get_csrf_token(app, environ)
visit_date = dbsession.query(models.Visit.visit_date).filter(
models.Patient.pid == u'123').scalar()
cycle_id = dbsession.query(models.Cycle.id).filter(
models.Cycle.name == u'TestCycle').scalar()
data = {
'cycles': [cycle_id],
'visit_date': '2015-01-02'
}
res = app.put_json(
self.url.format(visit_date),
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token,
'X-REQUESTED-WITH': str('XMLHttpRequest')
},
params=data)
assert 403 == res.status_code
示例4: test_not_allowed
def test_not_allowed(self, app, dbsession, group):
from occams import models
environ = make_environ(userid=USERID, groups=[group])
csrf_token = get_csrf_token(app, environ)
patient = dbsession.query(models.Patient).filter(
models.Patient.pid == u'123').one()
data = {
'initials': patient.initials,
'nurse': patient.nurse,
'site_id': patient.site_id,
'pid': patient.pid,
'site': patient.site_id
}
res = app.put_json(
self.url.format('123'),
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token,
'X-REQUESTED-WITH': str('XMLHttpRequest')
},
params=data)
assert 403 == res.status_code
示例5: test_not_allowed
def test_not_allowed(self, app, dbsession, group):
environ = make_environ(userid=USERID, groups=[group])
res = app.post(
self.url,
extra_environ=environ,
xhr=True,
status='*')
assert 403 == res.status_code
示例6: test_manage_external_services
def test_manage_external_services(self, app, dbsession, group):
environ = make_environ(userid=USERID, groups=[group])
res = app.get(
self.url,
extra_environ=environ,
params={})
assert 200 == res.status_code
示例7: test_filtered_site
def test_filtered_site(self, app, dbsession):
"""
Any authenticated user can view a site resources, but the listing
is filterd based on what sites they have access.
"""
environ = make_environ(userid=USERID, groups=['ucsd:member'])
res = app.get(
self.url, extra_environ=environ, xhr=True, status='*')
assert 200 == res.status_code
assert all('ucsd' == s['name'] for s in res.json['sites'])
示例8: test_allowed
def test_allowed(self, app, dbsession, group):
environ = make_environ(userid=USERID, groups=[group])
res = app.get(
self.url,
extra_environ=environ,
status='*',
xhr=True,
params={})
assert 200 == res.status_code
示例9: test_allowed
def test_allowed(self, app, dbsession, group):
environ = make_environ(userid=USERID, groups=[group])
res = app.get(self.url, extra_environ=environ, xhr=True)
data = res.json
csrf_token = get_csrf_token(app, environ)
res = app.delete_json(
self.url,
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token
},
params=data)
assert 200 == res.status_code
示例10: test_not_allowed
def test_not_allowed(self, app, group):
environ = make_environ(userid=USERID, groups=[group])
csrf_token = get_csrf_token(app, environ)
data = {
'title': 'test_study Week 1',
'week': '1'
}
res = app.post_json(
self.url.format('test_study'),
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token,
'X-REQUESTED-WITH': str('XMLHttpRequest')
},
params=data)
assert 403 == res.status_code
示例11: test_allowed
def test_allowed(self, app, group):
environ = make_environ(userid=USERID, groups=[group])
csrf_token = get_csrf_token(app, environ)
data = {
'name': 'TestDelete',
'title': 'TestDelete',
'week': 4
}
res = app.put_json(
self.url,
extra_environ=environ,
status='*',
headers={
'X-CSRF-Token': csrf_token,
'X-REQUESTED-WITH': str('XMLHttpRequest')
},
params=data)
assert 200 == res.status_code
示例12: test_randomize_ajax_not_allowed
def test_randomize_ajax_not_allowed(self, app, dbsession, factories, group):
import uuid
from occams import models
enrollment = dbsession.query(models.Enrollment).one()
url = '/studies/patients/{pid}/enrollments/{eid}/randomization'.format(
pid=enrollment.patient.pid,
eid=enrollment.id
)
environ = make_environ(userid=USERID, groups=[group])
headers = {
'X-CSRF-Token': get_csrf_token(app, environ),
'X-REQUESTED-WITH': str('XMLHttpRequest')
}
res = app.get(
url,
extra_environ=environ,
status='*',
headers=headers,
xhr=True,
)
assert 403 == res.status_code
procid = str(uuid.uuid4())
# CHALLENGE
res = app.post(
url,
extra_environ=environ,
status='*',
headers=headers,
xhr=True,
params={'procid': procid}
)
assert 403 == res.status_code
# ENTRY
res = app.post(
url,
extra_environ=environ,
status='*',
headers=headers,
xhr=True,
params={'procid': procid}
)
assert 403 == res.status_code
# VERIFY
res = app.post(
url,
extra_environ=environ,
status='*',
headers=headers,
xhr=True,
params={'procid': procid}
)
assert 403 == res.status_code