1
# Copyright 2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""These are yui appserver fixtures for the yui appserver test code's tests.
10
from zope.security.proxy import removeSecurityProxy
12
from lp.testing import login_person
13
from lp.testing.yuixhr import (
18
from lp.testing.factory import LaunchpadObjectFactory
20
# The following are the fixtures needed by the tests.
22
# We use this variable for test results.
26
def baseline(request, data):
27
data['hello'] = 'world'
30
def baseline(request, data):
32
_received.append(('baseline', request, data))
35
def second(request, data):
36
data['second'] = 'here'
38
def second(request, data):
40
_received.append(('second', request, data))
45
def faux_database_thing(request, data):
47
data['previous_value'] = test_value
49
@faux_database_thing.add_cleanup
50
def faux_database_thing(request, data):
52
test_value = 'teardown was called'
55
def show_teardown_value(request, data):
56
data['setup_data'] = 'Hello world'
57
@show_teardown_value.add_cleanup
58
def show_teardown_value(request, data):
62
factory = LaunchpadObjectFactory()
65
def make_product(request, data):
66
data['product'] = factory.makeProduct()
69
def make_product_loggedin(request, data):
70
data['person'] = factory.makeAdministrator()
71
login_person(data['person'])
72
data['product'] = factory.makeProduct(owner=data['person'])
75
def naughty_make_product(request, data):
76
data['product'] = removeSecurityProxy(factory.makeProduct())
79
def teardown_will_fail(request, data):
81
@teardown_will_fail.add_cleanup
82
def teardown_will_fail(request, data):
83
raise RuntimeError('rutebegas')
86
def login_as_admin(request, data):
87
data['user'] = factory.makeAdministrator()
88
login_as_person(data['user'])
91
return make_suite(__name__)