1
/* Copyright 2011 Canonical Ltd. This software is licensed under the
2
* GNU Affero General Public License version 3 (see the file LICENSE).
4
* Code to support full application server testing with YUI.
6
* @module Y.lp.testing.serverfixture
8
YUI.add('lp.testing.serverfixture', function(Y) {
10
var module = Y.namespace('lp.testing.serverfixture');
13
* This function calls fixture on the appserver side.
15
module.setup = function(testcase) {
16
// self-post, get data, stash/merge on testcase
17
var fixtures = Y.Array(arguments, 1);
18
var data = Y.QueryString.stringify(
20
fixtures: fixtures.join(',')
26
headers: {Accept: 'application/json'}
28
var response = Y.io(window.location, config);
29
if (response.status !== 200) {
30
Y.error(response.responseText);
32
var data = Y.JSON.parse(response.responseText);
33
if (!Y.Lang.isValue(testcase._lp_fixture_setups)) {
34
testcase._lp_fixture_setups = [];
36
testcase._lp_fixture_setups = testcase._lp_fixture_setups.concat(
38
if (!Y.Lang.isValue(testcase._lp_fixture_data)) {
39
testcase._lp_fixture_data = {};
41
testcase._lp_fixture_data = Y.merge(testcase._lp_fixture_data, data);
45
module.teardown = function(testcase) {
46
var fixtures = testcase._lp_fixture_setups;
47
var data = Y.QueryString.stringify(
49
fixtures: fixtures.join(','),
50
data: Y.JSON.stringify(testcase._lp_fixture_data)
57
var response = Y.io(window.location, config);
58
if (response.status !== 200) {
59
Y.error(response.responseText);
61
delete testcase._lp_fixture_setups;
62
delete testcase._lp_fixture_data;
65
}, "0.1", {"requires": ["io", "json", "querystring"]});