Merge lp:~allenap/launchpad/localpackagediffs-filter-by-package-set-bug-809786-refactor into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 13461
Proposed branch: lp:~allenap/launchpad/localpackagediffs-filter-by-package-set-bug-809786-refactor
Merge into: lp:launchpad
Diff against target: 518 lines (+171/-88)
6 files modified
Makefile (+11/-5)
lib/lp/app/javascript/testing/testrunner.js (+29/-0)
lib/lp/registry/browser/distroseries.py (+4/-0)
lib/lp/registry/javascript/distroseries.initseries.js (+55/-30)
lib/lp/registry/javascript/tests/test_distroseries.initseries.html (+29/-16)
lib/lp/registry/javascript/tests/test_distroseries.initseries.js (+43/-37)
To merge this branch: bzr merge lp:~allenap/launchpad/localpackagediffs-filter-by-package-set-bug-809786-refactor
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+68233@code.launchpad.net

Commit message

[r=benji][bug=809786] Refactor some DistroSeries JavaScript and add a declarative approach for running YUI tests.

Description of the change

This moves a few DistroSeries related bits of JavaScript around and
fixes some lint. The only thing that really needs reviewing is the new
code in lib/lp/app/javascript/testing/testrunner.js. Its doc comment:

/**
 * Merely loading this script into a page will cause it to look for a
 * list of suites in the document using the selector ul#suites>li. If
 * found, the text within each node is considered to be a test module
 * name. This is then loaded, and its "suite" property passed to
 * Runner.run().
 *
 * Here's how to declare the suites to run:
 *
 * <ul id="suites">
 * <li>lp.registry.distroseries.initseries.test</li>
 * </ul>
 *
 */

The test is then declared as a regular YUI module instead of
containing test run code.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2011-07-15 15:55:34 +0000
+++ Makefile 2011-07-18 11:54:37 +0000
@@ -25,11 +25,15 @@
25JS_BUILD := min25JS_BUILD := min
26endif26endif
2727
28JS_SOURCE_PATHS = -path './lib/lp/*/javascript/*' ! -path '*/tests/*' \28define JS_LP_PATHS
29 ! -path '*/testing/*' ! -path './lib/lp/services/*'29lib -path 'lib/lp/*/javascript/*' \
30! -path '*/tests/*' ! -path '*/testing/*' \
31! -path 'lib/lp/services/*'
32endef
33
30JS_YUI := $(shell utilities/yui-deps.py $(JS_BUILD:raw=))34JS_YUI := $(shell utilities/yui-deps.py $(JS_BUILD:raw=))
31JS_OTHER := $(wildcard lib/canonical/launchpad/javascript/*/*.js)35JS_OTHER := $(wildcard lib/canonical/launchpad/javascript/*/*.js)
32JS_LP := $(shell find $(JS_SOURCE_PATHS) -name '*.js' ! -name '.*.js' )36JS_LP := $(shell find $(JS_LP_PATHS) -name '*.js')
33JS_ALL := $(JS_YUI) $(JS_OTHER) $(JS_LP)37JS_ALL := $(JS_YUI) $(JS_OTHER) $(JS_LP)
34JS_OUT := $(LP_BUILT_JS_ROOT)/launchpad.js38JS_OUT := $(LP_BUILT_JS_ROOT)/launchpad.js
3539
@@ -164,7 +168,7 @@
164168
165jsbuild_widget_css: bin/jsbuild169jsbuild_widget_css: bin/jsbuild
166 ${SHHH} bin/jsbuild \170 ${SHHH} bin/jsbuild \
167 --srcdir lib/lp/app/javascript \171 --srcdir lib/lp/app/javascript \
168 --builddir $(LP_BUILT_JS_ROOT)172 --builddir $(LP_BUILT_JS_ROOT)
169173
170$(JS_LP): jsbuild_widget_css174$(JS_LP): jsbuild_widget_css
@@ -425,7 +429,9 @@
425copy-apache-config:429copy-apache-config:
426 # We insert the absolute path to the branch-rewrite script430 # We insert the absolute path to the branch-rewrite script
427 # into the Apache config as we copy the file into position.431 # into the Apache config as we copy the file into position.
428 sed -e 's,%BRANCH_REWRITE%,$(shell pwd)/scripts/branch-rewrite.py,' configs/development/local-launchpad-apache > /etc/apache2/sites-available/local-launchpad432 sed -e 's,%BRANCH_REWRITE%,$(shell pwd)/scripts/branch-rewrite.py,' \
433 configs/development/local-launchpad-apache > \
434 /etc/apache2/sites-available/local-launchpad
429 cp configs/development/local-vostok-apache \435 cp configs/development/local-vostok-apache \
430 /etc/apache2/sites-available/local-vostok436 /etc/apache2/sites-available/local-vostok
431 touch /var/tmp/bazaar.launchpad.dev/rewrite.log437 touch /var/tmp/bazaar.launchpad.dev/rewrite.log
432438
=== modified file 'lib/lp/app/javascript/testing/testrunner.js'
--- lib/lp/app/javascript/testing/testrunner.js 2011-07-08 06:06:15 +0000
+++ lib/lp/app/javascript/testing/testrunner.js 2011-07-18 11:54:37 +0000
@@ -39,3 +39,32 @@
39};39};
4040
41}, "0.1", {"requires": ["oop", "test", "console"]});41}, "0.1", {"requires": ["oop", "test", "console"]});
42
43
44/**
45 * Merely loading this script into a page will cause it to look for a
46 * list of suites in the document using the selector ul#suites>li. If
47 * found, the text within each node is considered to be a test module
48 * name. This is then loaded, and its "suite" property passed to
49 * Runner.run().
50 *
51 * Here's how to declare the suites to run:
52 *
53 * <ul id="suites">
54 * <li>lp.registry.distroseries.initseries.test</li>
55 * </ul>
56 *
57 */
58YUI().use("event", function(Y) {
59 Y.on("domready", function() {
60 var suites = Y.all("ul#suites > li");
61 Y.each(suites, function(suite_node) {
62 var suite_name = suite_node.get("text");
63 Y.use("lp.testing.runner", suite_name, function(y) {
64 var module = y, parts = suite_name.split(".");
65 while (parts.length > 0) { module = module[parts.shift()]; }
66 y.lp.testing.Runner.run(module.suite);
67 });
68 });
69 });
70});
4271
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2011-07-08 09:06:24 +0000
+++ lib/lp/registry/browser/distroseries.py 2011-07-18 11:54:37 +0000
@@ -827,6 +827,8 @@
827 super(DistroSeriesDifferenceBaseView, self).initialize()827 super(DistroSeriesDifferenceBaseView, self).initialize()
828828
829 def initialize_sync_label(self, label):829 def initialize_sync_label(self, label):
830 # XXX: GavinPanella 2011-07-13 bug=809985: Good thing the app servers
831 # are running single threaded...
830 self.__class__.actions.byname['actions.sync'].label = label832 self.__class__.actions.byname['actions.sync'].label = label
831833
832 @property834 @property
@@ -861,6 +863,8 @@
861 SimpleTerm(diff, diff.id)863 SimpleTerm(diff, diff.id)
862 for diff in self.cached_differences.batch]864 for diff in self.cached_differences.batch]
863 diffs_vocabulary = SimpleVocabulary(terms)865 diffs_vocabulary = SimpleVocabulary(terms)
866 # XXX: GavinPanella 2011-07-13 bug=809985: Good thing the app servers
867 # are running single threaded...
864 choice = self.form_fields['selected_differences'].field.value_type868 choice = self.form_fields['selected_differences'].field.value_type
865 choice.vocabulary = diffs_vocabulary869 choice.vocabulary = diffs_vocabulary
866870
867871
=== renamed file 'lib/lp/registry/javascript/distroseries.js' => 'lib/lp/registry/javascript/distroseries.initseries.js'
--- lib/lp/registry/javascript/distroseries.js 2011-06-27 17:04:27 +0000
+++ lib/lp/registry/javascript/distroseries.initseries.js 2011-07-18 11:54:37 +0000
@@ -22,7 +22,9 @@
22 *22 *
23 * @class FormRowWidget23 * @class FormRowWidget
24 */24 */
25var FormRowWidget = function() {25var FormRowWidget;
26
27FormRowWidget = function() {
26 FormRowWidget.superclass.constructor.apply(this, arguments);28 FormRowWidget.superclass.constructor.apply(this, arguments);
27};29};
2830
@@ -166,7 +168,9 @@
166 * can also be made an overlay, and a component and a pocket selected.168 * can also be made an overlay, and a component and a pocket selected.
167 *169 *
168 */170 */
169var ParentSeriesListWidget = function() {171var ParentSeriesListWidget;
172
173ParentSeriesListWidget = function() {
170 ParentSeriesListWidget174 ParentSeriesListWidget
171 .superclass.constructor.apply(this, arguments);175 .superclass.constructor.apply(this, arguments);
172};176};
@@ -466,7 +470,9 @@
466 *470 *
467 * @class ChoiceListWidget471 * @class ChoiceListWidget
468 */472 */
469var ChoiceListWidget = function() {473var ChoiceListWidget;
474
475ChoiceListWidget = function() {
470 ChoiceListWidget.superclass.constructor.apply(this, arguments);476 ChoiceListWidget.superclass.constructor.apply(this, arguments);
471};477};
472478
@@ -660,7 +666,9 @@
660 *666 *
661 * @class ArchitecturesChoiceListWidget667 * @class ArchitecturesChoiceListWidget
662 */668 */
663var ArchitecturesChoiceListWidget = function() {669var ArchitecturesChoiceListWidget;
670
671ArchitecturesChoiceListWidget = function() {
664 ArchitecturesChoiceListWidget672 ArchitecturesChoiceListWidget
665 .superclass.constructor.apply(this, arguments);673 .superclass.constructor.apply(this, arguments);
666};674};
@@ -726,14 +734,15 @@
726 */734 */
727 remove_distroseries: function(distroseries_id) {735 remove_distroseries: function(distroseries_id) {
728 // Compute which das is only in the distroseries to be removed.736 // Compute which das is only in the distroseries to be removed.
729 arch_to_remove = [];737 var arch_to_remove = [];
730 var das = this._distroseries[distroseries_id];738 var das = this._distroseries[distroseries_id];
731 var i, ds, j;739 var i, ds, j;
732 for (i=0; i<das.entries.length; i++) {740 for (i=0; i<das.entries.length; i++) {
733 remove_das = true;741 var remove_das = true;
734 arch = das.entries[i].get('architecture_tag');742 var arch = das.entries[i].get('architecture_tag');
735 for (ds in this._distroseries) {743 for (ds in this._distroseries) {
736 if (ds !== distroseries_id) {744 if (this._distroseries.hasOwnProperty(ds) &&
745 ds !== distroseries_id) {
737 var other_das = this._distroseries[ds];746 var other_das = this._distroseries[ds];
738 for (j=0; j<other_das.entries.length; j++) {747 for (j=0; j<other_das.entries.length; j++) {
739 var other_arch = other_das.entries[j].get(748 var other_arch = other_das.entries[j].get(
@@ -782,7 +791,9 @@
782 *791 *
783 * @class SelectWidget792 * @class SelectWidget
784 */793 */
785var SelectWidget = function() {794var SelectWidget;
795
796SelectWidget = function() {
786 SelectWidget.superclass.constructor.apply(this, arguments);797 SelectWidget.superclass.constructor.apply(this, arguments);
787};798};
788799
@@ -949,7 +960,9 @@
949 *960 *
950 * @class PackagesetPickerWidget961 * @class PackagesetPickerWidget
951 */962 */
952var PackagesetPickerWidget = function() {963var PackagesetPickerWidget;
964
965PackagesetPickerWidget = function() {
953 PackagesetPickerWidget966 PackagesetPickerWidget
954 .superclass.constructor.apply(this, arguments);967 .superclass.constructor.apply(this, arguments);
955};968};
@@ -1144,7 +1157,9 @@
1144 *1157 *
1145 * @class FormActionsWidget1158 * @class FormActionsWidget
1146 */1159 */
1147var FormActionsWidget = function() {1160var FormActionsWidget;
1161
1162FormActionsWidget = function() {
1148 FormActionsWidget1163 FormActionsWidget
1149 .superclass.constructor.apply(this, arguments);1164 .superclass.constructor.apply(this, arguments);
1150};1165};
@@ -1234,7 +1249,9 @@
1234 *1249 *
1235 * @class DeriveDistroSeriesActionsWidget1250 * @class DeriveDistroSeriesActionsWidget
1236 */1251 */
1237var DeriveDistroSeriesActionsWidget = function() {1252var DeriveDistroSeriesActionsWidget;
1253
1254DeriveDistroSeriesActionsWidget = function() {
1238 DeriveDistroSeriesActionsWidget1255 DeriveDistroSeriesActionsWidget
1239 .superclass.constructor.apply(this, arguments);1256 .superclass.constructor.apply(this, arguments);
1240};1257};
@@ -1333,7 +1350,8 @@
1333 add_parent_series(result);1350 add_parent_series(result);
1334 };1351 };
13351352
1336 parent_picker = Y.lp.app.picker.create('DistroSeriesDerivation', config);1353 var parent_picker =
1354 Y.lp.app.picker.create('DistroSeriesDerivation', config);
1337 parent_picker.show();1355 parent_picker.show();
1338};1356};
13391357
@@ -1354,17 +1372,21 @@
1354 *1372 *
1355 * @function setup1373 * @function setup
1356 */1374 */
1357namespace.setup = function() {1375namespace.setup = function(cache) {
1358 var form_actions = namespace.setupWidgets();1376 var form_actions = namespace.setupWidgets(cache);
1359 namespace.setupInteraction(form_actions);1377 namespace.setupInteraction(form_actions, cache);
1360};1378};
13611379
1362/**1380/**
1363 * Setup the widgets objects and return the form object.1381 * Setup the widgets objects and return the form object.
1364 *1382 *
1365 * @function setupWidgets1383 * @function setupWidgets
1384 * @param {Object} cache Specify the value cache to use. If not
1385 * specified, LP.cache is used. Intended chiefly for testing.
1366 */1386 */
1367namespace.setupWidgets = function() {1387namespace.setupWidgets = function(cache) {
1388 if (cache === undefined) { cache = LP.cache; }
1389
1368 var form_container = Y.one("#initseries-form-container");1390 var form_container = Y.one("#initseries-form-container");
1369 var form_table = form_container.one("table.form");1391 var form_table = form_container.one("table.form");
1370 var form_table_body = form_table.append(Y.Node.create('<tbody />'));1392 var form_table_body = form_table.append(Y.Node.create('<tbody />'));
@@ -1394,7 +1416,7 @@
1394 "architectures)."))1416 "architectures)."))
1395 .render(form_table_body);1417 .render(form_table_body);
1396 var packageset_choice = null;1418 var packageset_choice = null;
1397 if (LP.cache['is_first_derivation']) {1419 if (cache.is_first_derivation) {
1398 packageset_choice =1420 packageset_choice =
1399 new PackagesetPickerWidget()1421 new PackagesetPickerWidget()
1400 .set("name", "field.packagesets")1422 .set("name", "field.packagesets")
@@ -1424,7 +1446,7 @@
1424 .render(form_table_body);1446 .render(form_table_body);
1425 var form_actions =1447 var form_actions =
1426 new DeriveDistroSeriesActionsWidget({1448 new DeriveDistroSeriesActionsWidget({
1427 context: LP.cache.context,1449 context: cache.context,
1428 srcNode: form_container.one("div.actions"),1450 srcNode: form_container.one("div.actions"),
1429 deriveFromChoices: parents_selection,1451 deriveFromChoices: parents_selection,
1430 architectureChoice: architecture_choice,1452 architectureChoice: architecture_choice,
@@ -1440,10 +1462,14 @@
1440 * Setup the interaction between the widgets.1462 * Setup the interaction between the widgets.
1441 *1463 *
1442 * @function setupInteraction1464 * @function setupInteraction
1443 * @param {DeriveDistroSeriesActionsWidget} The form widget containing all1465 * @param {DeriveDistroSeriesActionsWidget} The form widget containing
1444 * the other widgets.1466 * all the other widgets.
1467 * @param {Object} cache Specify the value cache to use. If not
1468 * specified, LP.cache is used. Intended chiefly for testing.
1445 */1469 */
1446namespace.setupInteraction = function(form_actions) {1470namespace.setupInteraction = function(form_actions, cache) {
1471 if (cache === undefined) { cache = LP.cache; }
1472
1447 // Wire up the add parent series link.1473 // Wire up the add parent series link.
1448 var link = Y.one('#add-parent-series');1474 var link = Y.one('#add-parent-series');
1449 if (Y.Lang.isValue(link)) {1475 if (Y.Lang.isValue(link)) {
@@ -1458,7 +1484,7 @@
1458 }1484 }
1459 });1485 });
14601486
1461 if (LP.cache['is_first_derivation']) {1487 if (cache.is_first_derivation) {
1462 // Wire the architecture and packageset pickers to the parent picker.1488 // Wire the architecture and packageset pickers to the parent picker.
1463 Y.on('parent_added', function(parent) {1489 Y.on('parent_added', function(parent) {
1464 form_actions.architectureChoice.add_distroseries(parent);1490 form_actions.architectureChoice.add_distroseries(parent);
@@ -1471,7 +1497,7 @@
1471 });1497 });
1472 }1498 }
1473 else {1499 else {
1474 // Disable rebuilding if LP.cache['is_first_derivation'] is false.1500 // Disable rebuilding if cache.is_first_derivation is false.
1475 form_actions.packageCopyOptions.fieldNode1501 form_actions.packageCopyOptions.fieldNode
1476 .one('input[value="Copy Source and Rebuild"]')1502 .one('input[value="Copy Source and Rebuild"]')
1477 .set('disabled', 'disabled');1503 .set('disabled', 'disabled');
@@ -1485,13 +1511,12 @@
1485 "if you want to use all the available " +1511 "if you want to use all the available " +
1486 "architectures)."));1512 "architectures)."));
1487 form_actions.architectureChoice.add_distroseries(1513 form_actions.architectureChoice.add_distroseries(
1488 LP.cache['previous_series']);1514 cache.previous_series);
1489 // Setup the pre-selected parents (parents from the previous series).1515 // Setup the pre-selected parents (parents from the previous series).
1490 var index;1516 Y.each(
1491 for (index in LP.cache['previous_parents']) {1517 cache.previous_parents,
1492 form_actions.deriveFromChoices.add_parent(1518 form_actions.deriveFromChoices.add_parent,
1493 LP.cache['previous_parents'][index]);1519 form_actions.deriveFromChoices);
1494 }
1495 }1520 }
14961521
1497 // Wire up the form submission.1522 // Wire up the form submission.
14981523
=== renamed file 'lib/lp/registry/javascript/tests/test_distroseries.html' => 'lib/lp/registry/javascript/tests/test_distroseries.initseries.html'
--- lib/lp/registry/javascript/tests/test_distroseries.html 2011-07-08 06:06:15 +0000
+++ lib/lp/registry/javascript/tests/test_distroseries.initseries.html 2011-07-18 11:54:37 +0000
@@ -6,27 +6,40 @@
6 <title>Launchpad DistroSeries</title>6 <title>Launchpad DistroSeries</title>
77
8 <!-- YUI and test setup -->8 <!-- YUI and test setup -->
9 <script type="text/javascript"
10 src="../../../../canonical/launchpad/icing/yui/yui/yui.js">
11 </script>
12 <link rel="stylesheet" href="../../../app/javascript/testing/test.css" />9 <link rel="stylesheet" href="../../../app/javascript/testing/test.css" />
13 <script type="text/javascript"10 <script type="text/javascript"
11 src="../../../../canonical/launchpad/icing/yui/yui/yui.js"></script>
12 <script type="text/javascript"
14 src="../../../app/javascript/testing/testrunner.js"></script>13 src="../../../app/javascript/testing/testrunner.js"></script>
1514
16 <!-- Required modules -->15 <!-- Required modules -->
17 <script type="text/javascript" src="../../../app/javascript/client.js"></script>16 <script type="text/javascript"
18 <script type="text/javascript" src="../../../app/javascript/activator/activator.js"></script>17 src="../../../app/javascript/client.js"></script>
19 <script type="text/javascript" src="../../../app/javascript/anim/anim.js"></script>18 <script type="text/javascript"
20 <script type="text/javascript" src="../../../app/javascript/lazr/lazr.js"></script>19 src="../../../app/javascript/activator/activator.js"></script>
21 <script type="text/javascript" src="../../../app/javascript/overlay/overlay.js"></script>20 <script type="text/javascript"
22 <script type="text/javascript" src="../../../app/javascript/picker/picker.js"></script>21 src="../../../app/javascript/anim/anim.js"></script>
23 <script type="text/javascript" src="../../../app/javascript/picker/person_picker.js"></script>22 <script type="text/javascript"
24 <script type="text/javascript" src="../../../app/javascript/picker/picker_patcher.js"></script>23 src="../../../app/javascript/lazr/lazr.js"></script>
25 <!-- The module under test -->24 <script type="text/javascript"
26 <script type="text/javascript" src="../distroseries.js"></script>25 src="../../../app/javascript/overlay/overlay.js"></script>
27 <!-- The test suite -->26 <script type="text/javascript"
28 <script type="text/javascript" src="test_distroseries.js"></script>27 src="../../../app/javascript/picker/picker.js"></script>
28 <script type="text/javascript"
29 src="../../../app/javascript/picker/person_picker.js"></script>
30 <script type="text/javascript"
31 src="../../../app/javascript/picker/picker_patcher.js"></script>
32
33 <!-- The module under test -->
34 <script type="text/javascript" src="../distroseries.initseries.js"></script>
35
36 <!-- The test suite -->
37 <script type="text/javascript" src="test_distroseries.initseries.js"></script>
38
29 </head>39 </head>
30 <body class="yui3-skin-sam">40 <body class="yui3-skin-sam">
41 <ul id="suites">
42 <li>lp.registry.distroseries.initseries.test</li>
43 </ul>
31 </body>44 </body>
32</html>45</html>
3346
=== renamed file 'lib/lp/registry/javascript/tests/test_distroseries.js' => 'lib/lp/registry/javascript/tests/test_distroseries.initseries.js'
--- lib/lp/registry/javascript/tests/test_distroseries.js 2011-07-08 05:39:39 +0000
+++ lib/lp/registry/javascript/tests/test_distroseries.initseries.js 2011-07-18 11:54:37 +0000
@@ -1,9 +1,16 @@
1/* Copyright (c) 2011, Canonical Ltd. All rights reserved. */1/**
22 * Copyright 2011 Canonical Ltd. This software is licensed under the
3YUI().use(3 * GNU Affero General Public License version 3 (see the file LICENSE).
4 'lp.testing.runner', 'test', 'console', 'node-event-simulate',4 *
5 'lp.registry.distroseries.initseries',5 * Tests for DistroSeries related stuff.
6 function(Y) {6 *
7 * @module lp.registry.distroseries
8 * @submodule test
9 */
10
11YUI.add('lp.registry.distroseries.initseries.test', function(Y) {
12
13 var namespace = Y.namespace('lp.registry.distroseries.initseries.test');
714
8 var Assert = Y.Assert;15 var Assert = Y.Assert;
9 var ArrayAssert = Y.ArrayAssert;16 var ArrayAssert = Y.ArrayAssert;
@@ -440,6 +447,7 @@
440 },447 },
441448
442 testParentGetter: function() {449 testParentGetter: function() {
450 var parent;
443 parent = {value: "4", title: "Hoary", api_uri: "ubuntu/hoary"};451 parent = {value: "4", title: "Hoary", api_uri: "ubuntu/hoary"};
444 this.widget.add_parent(parent);452 this.widget.add_parent(parent);
445 parent = {value: "3", title: "Warty", api_uri: "ubuntu/warty"};453 parent = {value: "3", title: "Warty", api_uri: "ubuntu/warty"};
@@ -495,7 +503,7 @@
495 Assert.isFunction(config.on.failure);503 Assert.isFunction(config.on.failure);
496 }504 }
497 };505 };
498 distroseries = {api_uri: "ubuntu/hoary", value: 3};506 var distroseries = {api_uri: "ubuntu/hoary", value: 3};
499 this.widget.add_distroseries(distroseries);507 this.widget.add_distroseries(distroseries);
500 Assert.isTrue(io, "No IO initiated.");508 Assert.isTrue(io, "No IO initiated.");
501 },509 },
@@ -1056,6 +1064,10 @@
1056 else if (name === "overlay_components") {1064 else if (name === "overlay_components") {
1057 return ['restricted', null];1065 return ['restricted', null];
1058 }1066 }
1067 else {
1068 Assert.fail("Unrecognized property: " + name);
1069 return null; // Keep lint quiet.
1070 }
1059 }1071 }
1060 },1072 },
1061 architectureChoice: {1073 architectureChoice: {
@@ -1169,30 +1181,10 @@
1169 Y.one('body').appendChild(node);1181 Y.one('body').appendChild(node);
1170 },1182 },
11711183
1172 setUpFirstDerivation: function() {
1173 window.LP = {cache: {is_first_derivation: true}};
1174 },
1175
1176 setUpNotFirstDerivation: function() {
1177 window.LP = {cache:
1178 {is_first_derivation: false,
1179 previous_series: {
1180 api_uri: '/ubuntu/natty',
1181 value: '3',
1182 title: 'Ubunty: Natty'},
1183 previous_parents: [
1184 {api_uri: '/debian/sid',
1185 value: '4',
1186 title: 'Debian: Sid'},
1187 {api_uri: '/zz/aa',
1188 value: '5',
1189 title: 'ZZ: aa'}]}};
1190 },
1191
1192 testIsFirstDerivation: function() {1184 testIsFirstDerivation: function() {
1193 this.setUpFirstDerivation();1185 var cache = {is_first_derivation: true};
1194 var form_actions = initseries.setupWidgets();1186 var form_actions = initseries.setupWidgets(cache);
1195 initseries.setupInteraction(form_actions);1187 initseries.setupInteraction(form_actions, cache);
11961188
1197 // No pre-populated parent.1189 // No pre-populated parent.
1198 ArrayAssert.itemsAreEqual(1190 ArrayAssert.itemsAreEqual(
@@ -1201,8 +1193,21 @@
1201 },1193 },
12021194
1203 testIsNotFirstDerivation: function() {1195 testIsNotFirstDerivation: function() {
1204 this.setUpNotFirstDerivation();1196 var cache = {
1205 var form_actions = initseries.setupWidgets();1197 is_first_derivation: false,
1198 previous_series: {
1199 api_uri: '/ubuntu/natty',
1200 value: '3',
1201 title: 'Ubunty: Natty'
1202 },
1203 previous_parents: [
1204 {api_uri: '/debian/sid',
1205 value: '4', title: 'Debian: Sid'},
1206 {api_uri: '/zz/aa',
1207 value: '5', title: 'ZZ: aa'}
1208 ]
1209 };
1210 var form_actions = initseries.setupWidgets(cache);
1206 // Monkeypatch LP client.1211 // Monkeypatch LP client.
1207 var client = {1212 var client = {
1208 get: function(path, config) {1213 get: function(path, config) {
@@ -1220,7 +1225,7 @@
1220 }1225 }
1221 };1226 };
1222 form_actions.architectureChoice.client = client;1227 form_actions.architectureChoice.client = client;
1223 initseries.setupInteraction(form_actions);1228 initseries.setupInteraction(form_actions, cache);
12241229
1225 // Parents are populated.1230 // Parents are populated.
1226 ArrayAssert.itemsAreEqual(1231 ArrayAssert.itemsAreEqual(
@@ -1237,7 +1242,8 @@
1237 };1242 };
12381243
1239 suite.add(new Y.Test.Case(testDeriveDistroSeriesSetup));1244 suite.add(new Y.Test.Case(testDeriveDistroSeriesSetup));
12401245 namespace.suite = suite;
1241 Y.lp.testing.Runner.run(suite);1246
12421247}, "0.1", {"requires": [
1243});1248 'test', 'console', 'node-event-simulate',
1249 'lp.registry.distroseries.initseries']});