Merge "fix unit tests"

This commit is contained in:
Jenkins 2016-04-18 15:04:37 +00:00 committed by Gerrit Code Review
commit 528567509d
4 changed files with 40 additions and 42 deletions

1
.gitignore vendored
View File

@ -30,6 +30,7 @@ nosetests.xml
.venv .venv
node_modules node_modules
coverage* coverage*
test-shim.js
# Translations # Translations
*.mo *.mo

View File

@ -20,24 +20,8 @@ var fs = require('fs');
var path = require('path'); var path = require('path');
module.exports = function (config) { module.exports = function (config) {
var xstaticPath; // This tox venv is setup in the post-install npm step
var basePaths = [ var toxPath = '../.tox/py27/lib/python2.7/site-packages/';
'../horizon/.venv'
];
for (var i = 0; i < basePaths.length; i++) {
var basePath = path.resolve(basePaths[i]);
if (fs.existsSync(basePath)) {
xstaticPath = basePath + '/lib/python2.7/site-packages/xstatic/pkg/';
break;
}
}
if (!xstaticPath) {
console.error('xStatic libraries not found, please set up venv');
process.exit(1);
}
config.set({ config.set({
preprocessors: { preprocessors: {
@ -54,7 +38,6 @@ module.exports = function (config) {
moduleName: 'templates' moduleName: 'templates'
}, },
// Assumes you're in the top-level horizon directory.
basePath: './', basePath: './',
// Contains both source and test files. // Contains both source and test files.
@ -64,38 +47,38 @@ module.exports = function (config) {
* Contains expected items not provided elsewhere (dynamically by * Contains expected items not provided elsewhere (dynamically by
* Django or via jasmine template. * Django or via jasmine template.
*/ */
'../../horizon/test-shim.js', '../test-shim.js',
// from jasmine.html // from jasmine.html
xstaticPath + 'jquery/data/jquery.js', toxPath + 'xstatic/pkg/jquery/data/jquery.js',
xstaticPath + 'angular/data/angular.js', toxPath + 'xstatic/pkg/angular/data/angular.js',
xstaticPath + 'angular/data/angular-route.js', toxPath + 'xstatic/pkg/angular/data/angular-route.js',
xstaticPath + 'angular/data/angular-mocks.js', toxPath + 'xstatic/pkg/angular/data/angular-mocks.js',
xstaticPath + 'angular/data/angular-cookies.js', toxPath + 'xstatic/pkg/angular/data/angular-cookies.js',
xstaticPath + 'angular_bootstrap/data/angular-bootstrap.js', toxPath + 'xstatic/pkg/angular_bootstrap/data/angular-bootstrap.js',
xstaticPath + 'angular_gettext/data/angular-gettext.js', toxPath + 'xstatic/pkg/angular_gettext/data/angular-gettext.js',
xstaticPath + 'angular/data/angular-sanitize.js', toxPath + 'xstatic/pkg/angular/data/angular-sanitize.js',
xstaticPath + 'd3/data/d3.js', toxPath + 'xstatic/pkg/d3/data/d3.js',
xstaticPath + 'rickshaw/data/rickshaw.js', toxPath + 'xstatic/pkg/rickshaw/data/rickshaw.js',
xstaticPath + 'angular_smart_table/data/smart-table.js', toxPath + 'xstatic/pkg/angular_smart_table/data/smart-table.js',
xstaticPath + 'angular_lrdragndrop/data/lrdragndrop.js', toxPath + 'xstatic/pkg/angular_lrdragndrop/data/lrdragndrop.js',
xstaticPath + 'spin/data/spin.js', toxPath + 'xstatic/pkg/spin/data/spin.js',
xstaticPath + 'spin/data/spin.jquery.js', toxPath + 'xstatic/pkg/spin/data/spin.jquery.js',
// TODO: These should be mocked. // TODO: These should be mocked.
'../../horizon/horizon/static/horizon/js/horizon.js', toxPath + '/horizon/static/horizon/js/horizon.js',
/** /**
* Include framework source code from horizon that we need. * Include framework source code from horizon that we need.
* Otherwise, karma will not be able to find them when testing. * Otherwise, karma will not be able to find them when testing.
* These files should be mocked in the foreseeable future. * These files should be mocked in the foreseeable future.
*/ */
'../../horizon/horizon/static/framework/**/*.module.js', toxPath + 'horizon/static/framework/**/*.module.js',
'../../horizon/horizon/static/framework/**/!(*.spec|*.mock).js', toxPath + 'horizon/static/framework/**/!(*.spec|*.mock).js',
'../../horizon/openstack_dashboard/static/**/*.module.js', toxPath + 'openstack_dashboard/static/**/*.module.js',
'../../horizon/openstack_dashboard/static/**/!(*.spec|*.mock).js', toxPath + 'openstack_dashboard/static/**/!(*.spec|*.mock).js',
'../../horizon/openstack_dashboard/dashboards/**/static/**/*.module.js', toxPath + 'openstack_dashboard/dashboards/**/static/**/*.module.js',
'../../horizon/openstack_dashboard/dashboards/**/static/**/!(*.spec|*.mock).js', toxPath + 'openstack_dashboard/dashboards/**/static/**/!(*.spec|*.mock).js',
/** /**
* First, list all the files that defines application's angular modules. * First, list all the files that defines application's angular modules.
@ -116,7 +99,7 @@ module.exports = function (config) {
* Then, list files for mocks with `mock.js` extension. The order * Then, list files for mocks with `mock.js` extension. The order
* among them should not be significant. * among them should not be significant.
*/ */
'../../horizon/openstack_dashboard/static/**/*.mock.js', toxPath + 'openstack_dashboard/static/**/*.mock.js',
//'./static/**/*.mock.js', //'./static/**/*.mock.js',
/** /**

View File

@ -0,0 +1,13 @@
#!/bin/bash -x
# This script will be executed inside npm postinstall task, see package.json
# pull down the test shim from horizon master because it's not
# included in the installed horizon packages
if [ ! -f test-shim.js ];
then
wget -nv -t 3 https://raw.githubusercontent.com/openstack/horizon/master/test-shim.js
fi
echo "Creating a tox env which will contain xStatic libraries, horizon, and openstack_dashboard"
tox -epy27 --notest;

View File

@ -21,6 +21,7 @@
"phantomjs": "1.9.17" "phantomjs": "1.9.17"
}, },
"scripts": { "scripts": {
"postinstall": "neutron_lbaas_dashboard/post_install.sh",
"test": "karma start neutron_lbaas_dashboard/karma.conf.js --single-run", "test": "karma start neutron_lbaas_dashboard/karma.conf.js --single-run",
"lint": "eslint --no-color neutron_lbaas_dashboard/static" "lint": "eslint --no-color neutron_lbaas_dashboard/static"
}, },