本文整理汇总了Python中test.fixtures.make_fake_space函数的典型用法代码示例。如果您正苦于以下问题:Python make_fake_space函数的具体用法?Python make_fake_space怎么用?Python make_fake_space使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_fake_space函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_spaces_list
def test_spaces_list():
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/spaces',
method='GET')
assert response['status'] == '200'
assert response['cache-control'] == 'no-cache'
info = simplejson.loads(content)
uris = [uri for _, uri in [item.values() for item in info]]
names = [name for name, _ in [item.values() for item in info]]
expected_uris = ['http://0.0.0.0:8080/', 'http://cdent.0.0.0.0:8080/']
expected_uris.extend(SYSTEM_URLS)
expected_names = ['cdent', 'frontpage']
expected_names.extend(SYSTEM_SPACES)
assert sorted(uris) == sorted(expected_uris)
assert sorted(names) == sorted(expected_names)
make_fake_space(store, 'fnd')
response, content = http.request('http://0.0.0.0:8080/spaces',
method='GET')
assert response['status'] == '200'
info = simplejson.loads(content)
uris = [uri for _, uri in [item.values() for item in info]]
assert 'http://cdent.0.0.0.0:8080/' in uris
assert 'http://fnd.0.0.0.0:8080/' in uris
示例2: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn)
module.http = httplib2.Http()
make_fake_space(store, 'thing')
示例3: setup_module
def setup_module(module):
make_test_env(module)
# we have to have a function that returns the callable,
# Selector just _is_ the callable
make_fake_space(module.store, 'cdent')
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
示例4: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
module.http = httplib2.Http()
make_fake_space(module.store, 'cdent')
module.store.put(User('cdent'))
示例5: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept("thing.0.0.0.0", 8080, app_fn)
make_fake_space(store, "thing")
module.http = httplib2.Http()
tiddler = Tiddler("OhHi", "thing_public")
tiddler.text = "!Hi\n"
store.put(tiddler)
示例6: setup_module
def setup_module(module):
make_test_env(module, hsearch=True)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('fnd.0.0.0.0', 8080, app_fn)
make_fake_space(module.store, 'cdent')
make_fake_space(module.store, 'fnd')
user = User('cdent')
user.set_password('cow')
module.store.put(user)
module.http = httplib2.Http()
示例7: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn)
make_fake_space(store, 'thing')
tiddler = Tiddler('ServerSettings', 'thing_public')
tiddler.text = 'htmltemplate: clean1\n'
store.put(tiddler)
tiddler = Tiddler('TestMe', 'thing_public')
tiddler.text = '# Hi\n\n# one\n# two'
tiddler.tags = ['alpha', 'beta', '12th monkey']
store.put(tiddler)
module.http = httplib2.Http()
示例8: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('bar.example.com', 8080, app_fn)
make_fake_space(module.store, 'cdent')
user = User('cdent')
user.set_password('cow')
module.store.put(user)
module.auth = b64encode('cdent:cow')
user = User('fnd')
user.set_password('pig')
module.store.put(user)
module.badauth = b64encode('fnd:pig')
module.http = httplib2.Http()
示例9: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
from tiddlyweb.config import config
config['blacklisted_spaces'] = ['scrappy']
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
make_fake_space(module.store, 'cdent')
user = User('cdent')
user.set_password('cow')
module.store.put(user)
user = User('fnd')
user.set_password('bird')
module.store.put(user)
user = User('psd')
user.set_password('cat')
module.store.put(user)
示例10: test_disable_ControlView
def test_disable_ControlView():
make_fake_space(store, 'foo')
make_fake_space(store, 'bar')
http = httplib2.Http()
response, content = http.request('http://foo.0.0.0.0:8080/recipes',
method='GET')
assert 'foo_public' in content, content
assert 'bar_public' not in content, content
response, content = http.request('http://foo.0.0.0.0:8080/recipes',
headers={'X-ControlView': 'false'},
method='GET')
assert 'foo_public' in content, content
assert 'bar_public' in content, content
response, content = http.request('http://foo.0.0.0.0:8080/recipes',
headers={'X-ControlView': 'true'},
method='GET')
assert 'foo_public' in content, content
assert 'bar_public' not in content, content
示例11: setup_module
def setup_module(module):
make_test_env(module)
httplib2_intercept.install()
wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
make_fake_space(module.store, 'fnd')
make_fake_space(module.store, 'cdent')
make_fake_space(module.store, 'psd')
users = {
'fnd': 'foo',
'cdent': 'bar',
'psd': 'baz'
}
for username, password in users.items():
user = User(username)
user.set_password(password)
module.store.put(user)
示例12: test_space_has_limited_view
def test_space_has_limited_view():
make_fake_space(store, 'other')
http = httplib2.Http()
response, content = http.request('http://thing.0.0.0.0:8080/recipes',
method='GET')
assert response['status'] == '200'
assert 'other_' not in content, content
assert 'thing_' in content, content
response, content = http.request('http://thing.0.0.0.0:8080/bags',
method='GET')
assert response['status'] == '200'
assert 'other_' not in content, content
assert 'thing_' in content, content
response, content = http.request(
'http://thing.0.0.0.0:8080/bags/thing_public/tiddlers',
method='GET')
assert response['status'] == '200'
response, content = http.request(
'http://thing.0.0.0.0:8080/bags/other_public/tiddlers',
method='GET')
assert response['status'] == '404', content
response, content = http.request(
'http://other.0.0.0.0:8080/bags',
method='GET')
assert response['status'] == '200', content
assert 'other_' in content, content
assert 'thing_' not in content, content
response, content = http.request(
'http://0.0.0.0:8080/bags',
method='GET')
assert response['status'] == '200', content
assert 'other_' in content, content
assert 'thing_' in content, content
response, content = http.request(
'http://thing.0.0.0.0:8080/bags/thing_public/tiddlers',
method='GET')
assert response['status'] == '200', content
response, content = http.request(
'http://thing.0.0.0.0:8080/bags/other_public/tiddlers',
method='GET')
assert response['status'] == '404', content
tiddler1 = Tiddler('tiddler1', 'thing_public')
tiddler2 = Tiddler('tiddler2', 'other_public')
tiddler1.text = tiddler2.text = 'ohhai'
store.put(tiddler1)
store.put(tiddler2)
response, content = http.request(
'http://thing.0.0.0.0:8080/search?q=ohhai',
headers={'Accept': 'application/json'},
method='GET')
assert response['status'] == '200', content
info = simplejson.loads(content)
assert len(info) == 1
assert info[0]['title'] == tiddler1.title
response, content = http.request(
'http://other.0.0.0.0:8080/search?q=ohhai',
headers={'Accept': 'application/json'},
method='GET')
assert response['status'] == '200', content
info = simplejson.loads(content)
assert len(info) == 1
assert info[0]['title'] == tiddler2.title
response, content = http.request(
'http://0.0.0.0:8080/search?q=ohhai',
headers={'Accept': 'application/json'},
method='GET')
assert response['status'] == '200', content
info = simplejson.loads(content)
assert len(info) == 2
示例13: test_space_does_exist
def test_space_does_exist():
make_fake_space(store, 'thing')
http = httplib2.Http()
response, content = http.request('http://thing.0.0.0.0:8080/', method='GET')
assert response['status'] == '200'
示例14: test_space_not_expose_subscription_recipes
def test_space_not_expose_subscription_recipes():
make_fake_space(store, 'foo')
make_fake_space(store, 'bar')
make_fake_space(store, 'baz')
# add subscription (manual as this is currently insufficiently encapsulated)
public_recipe = store.get(Recipe('foo_public'))
private_recipe = store.get(Recipe('foo_private'))
public_recipe_list = public_recipe.get_recipe()
private_recipe_list = private_recipe.get_recipe()
public_recipe_list.insert(-1, ('bar_public', ''))
private_recipe_list.insert(-2, ('bar_public', ''))
public_recipe.set_recipe(public_recipe_list)
private_recipe.set_recipe(private_recipe_list)
store.put(public_recipe)
store.put(private_recipe)
http = httplib2.Http()
user = User('foo')
user.set_password('foobar')
store.put(user)
user_cookie = get_auth('foo', 'foobar')
response, content = http.request('http://foo.0.0.0.0:8080/recipes',
method='GET')
assert response['status'] == '200'
assert 'foo_public' in content, content
assert 'foo_private' not in content, content # not auth'd
assert 'bar_public' not in content, content
assert 'bar_private' not in content, content
assert 'baz_' not in content, content
response, content = http.request('http://foo.0.0.0.0:8080/recipes/foo_public',
method='GET')
assert response['status'] == '200'
response, content = http.request('http://foo.0.0.0.0:8080/recipes/foo_private',
method='GET',
headers={
'Cookie': 'tiddlyweb_user="%s"' % user_cookie
})
assert response['status'] == '200'
response, content = http.request('http://foo.0.0.0.0:8080/recipes/bar_public',
method='GET')
assert response['status'] == '404'
response, content = http.request('http://foo.0.0.0.0:8080/recipes/bar_private',
method='GET',
headers={
'Cookie': 'tiddlyweb_user="%s"' % user_cookie
})
assert response['status'] == '404'
response, content = http.request('http://foo.0.0.0.0:8080/recipes/baz_public',
method='GET')
assert response['status'] == '404'
response, content = http.request('http://foo.0.0.0.0:8080/recipes/baz_private',
method='GET')
assert response['status'] == '404'