Commit 3debb3dd authored by Thibaut Frain's avatar Thibaut Frain

added python package to exec phantomjs tests ($ python2 setup.py test)

parent dadffaa3
import os
from setuptools import setup, find_packages
setup(
name = "test_launcher_for_officejs",
version = "0.0.4",
author = "Sebastien Robin",
author_email = "andrewjcarter@gmail.com",
description = ("only launch officejs test."),
license = "GPL",
keywords = "officejs test",
url = "http://j-io.org",
packages=['test_launcher_for_officejs', 'test_launcher_for_officejs.tests'],
long_description="",
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: GPL License",
],
test_suite='test_launcher_for_officejs.tests',
)
......@@ -13,7 +13,7 @@
})
.declareMethod('setContent', function (content) {
console.log('setcontent:' + content);
//console.log('setcontent:' + content);
rJS(this).editor.html(content);
})
......
/*global window, jQuery, jIO, rJS */
/*jslint unparam: true*/
"use strict";
(function (window, $, jIO, rJS) {
......@@ -27,7 +28,7 @@
deferred.reject(err);
}
} else {
console.log("getIO: " + response);
//console.log("getIO: " + response);
deferred.resolve(response || default_value);
}
});
......@@ -38,7 +39,6 @@
.declareMethod('setIO', function (value) {
//console.log("couscous");
var deferred = $.Deferred(),
default_value = "",
gadget = rJS(this);
gadget.jio.put({"_id": gadget.jio_key},
function (err, response) {
......@@ -55,7 +55,7 @@
if (err) {
deferred.reject(err);
} else {
console.log("putIO: " + value);
//console.log("putIO: " + value);
deferred.resolve();
}
});
......
......@@ -32,7 +32,7 @@
rJS(window).declareMethod('getContent', function () {
var content = JSON.stringify($.sheet.instance[0].exportSheet.json());
console.log("function getContent" + content);
//console.log("function getContent" + content);
return content;
})
......@@ -40,7 +40,7 @@
var config = $.extend({
buildSheet: $.sheet.makeTable.json(JSON.parse(content))
}, default_config);
console.log(config.buildSheet);
//console.log(config.buildSheet);
init.apply(rJS(this), [config]);
})
......
running test
running egg_info
writing test_launcher_for_officejs.egg-info/PKG-INFO
writing top-level names to test_launcher_for_officejs.egg-info/top_level.txt
writing dependency_links to test_launcher_for_officejs.egg-info/dependency_links.txt
reading manifest file 'test_launcher_for_officejs.egg-info/SOURCES.txt'
writing manifest file 'test_launcher_for_officejs.egg-info/SOURCES.txt'
running build_ext
['/home/th/NEXEDI/officejs//node_modules/.bin/phantomjs /home/th/NEXEDI/officejs//test/run-qunit.js /home/th/NEXEDI/officejs//test/officejs.html; exit 0']
'waitFor()' finished in 1568ms.
========================================================
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height">
<title>✔ Test OfficeJS gadgets</title>
<link rel="stylesheet" href="../src/lib/qunit/qunit.css">
<script src="../src/lib/jquery.js"></script>
<script src="../src/lib/qunit/qunit.js"></script>
<script src="../src/lib/sinon/sinon.js"></script>
<script src="../src/lib/jschannel.js"></script>
<script src="../src/lib/renderjs.js"></script>
<script src="bw-gadget-test.js"></script>
<script src="jqs-gadget-test.js"></script>
</head>
<body style="">
<div id="qunit"><h1 id="qunit-header"><a href="file:///home/th/NEXEDI/officejs/test/officejs.html">Test OfficeJS gadgets</a> </h1><h2 id="qunit-banner" class="qunit-pass"></h2><div id="qunit-testrunner-toolbar"><input type="checkbox" id="qunit-filter-pass"><label for="qunit-filter-pass" title="Only show tests and assertions that fail. Stored in sessionStorage.">Hide passed tests</label><span><input id="qunit-urlconfig-noglobals" name="noglobals" type="checkbox" title="Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."><label for="qunit-urlconfig-noglobals" title="Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings.">Check for Globals</label><input id="qunit-urlconfig-notrycatch" name="notrycatch" type="checkbox" title="Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."><label for="qunit-urlconfig-notrycatch" title="Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings.">No try-catch</label></span></div><h2 id="qunit-userAgent">Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.2 Safari/534.34</h2><p id="qunit-testresult" class="result">Tests completed in 1389 milliseconds.<br><span class="passed">18</span> assertions of <span class="total">18</span> passed, <span class="failed">0</span> failed.</p><ol id="qunit-tests"><li class="pass" id="qunit-test-output0"><strong><span class="test-name">Bootstrap wysiwyg loading</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">1</b>, 1)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=1">Rerun</a><span class="runtime">432 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output1"><strong><span class="test-name">Bootstrap wysiwyg loading : textarea is empty</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">1</b>, 1)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=2">Rerun</a><span class="runtime">64 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output2"><strong><span class="test-name">clear content of editor</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">1</b>, 1)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=3">Rerun</a><span class="runtime">65 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output3"><strong><span class="test-name">get content of editor</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">1</b>, 1)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=4">Rerun</a><span class="runtime">64 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output4"><strong><span class="test-name">set content of sheet</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">2</b>, 2)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=5">Rerun</a><span class="runtime">67 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output5"><strong><span class="test-name">jquery.sheet loading : sheet loads</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">2</b>, 2)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=6">Rerun</a><span class="runtime">110 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output6"><strong><span class="test-name">jquery.sheet loading : sheet is empty</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">2</b>, 2)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=7">Rerun</a><span class="runtime">99 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output7"><strong><span class="test-name">clear content</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">2</b>, 2)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=8">Rerun</a><span class="runtime">151 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output8"><strong><span class="test-name">get content of sheet</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">2</b>, 2)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=9">Rerun</a><span class="runtime">108 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li></ol></li><li class="pass" id="qunit-test-output9"><strong><span class="test-name">set content of sheet</span> <b class="counts">(<b class="failed">0</b>, <b class="passed">4</b>, 4)</b></strong><a href="file:///home/th/NEXEDI/officejs/test/officejs.html?testNumber=10">Rerun</a><span class="runtime">207 ms</span><ol class="qunit-assert-list qunit-collapsed"><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li><li class="pass"><span class="test-message">okay</span></li></ol></li></ol></div>
<div id="qunit-fixture"></div>
<div id="gadget" style="display:none;"><iframe src="../deploy/gadget/jqs.html"></iframe></div>
</body>
========================================================
Tests completed in 1389 milliseconds.
18 assertions of 18 passed, 0 failed.
OFFICEJS SUB RESULT: 18 Tests, 0 Failures
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height"/>
<title>Test OfficeJS gadgets</title>
<link rel="stylesheet" href="../src/lib/qunit/qunit.css">
<script src="../src/lib/jquery.js"></script>
<script src="../src/lib/qunit/qunit.js"></script>
<script src="../src/lib/sinon/sinon.js"></script>
<script src="../src/lib/jschannel.js"></script>
<script src="../src/lib/renderjs.js"></script>
<script src="bw-gadget-test.js"></script>
<script src="jqs-gadget-test.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="gadget" style="display:none;"></div>
</body>
</html>
/*jslint indent: 2, maxlen: 80 */
/*global require, phantom, document, setInterval, clearInterval, console */
(function () {
"use strict";
var system = require('system'), page;
/**
* Wait until the test condition is true or a timeout occurs. Useful for
* waiting on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @method waitFor
* @param {Function} testFx Condition that evaluates to a boolean
* @param {Function} onReady What to do when testFx condition is fulfilled
* @param {Number} time_out_millis The max amount of time to wait.
* If not specified, 10 sec is used.
*/
function waitFor(testFx, onReady, time_out_millis) {
var maxtime_out_millis, start, condition, interval;
maxtime_out_millis = time_out_millis || 10001;
start = new Date().getTime();
condition = false;
interval = setInterval(function () {
if ((new Date().getTime() - start < maxtime_out_millis) && !condition) {
// If not time-out yet and condition not yet fulfilled
condition = testFx();
} else {
if (!condition) {
// If condition still not fulfilled (timeout but condition is 'false')
console.log("'waitFor()' timeout");
phantom.exit(1);
} else {
// Condition fulfilled (timeout and/or condition is 'true')
console.log("'waitFor()' finished in " +
(new Date().getTime() - start) + "ms.");
onReady();
clearInterval(interval); //< Stop this interval
}
}
}, 100); //< repeat check every 100ms
}
if (system.args.length !== 2) {
console.log('Usage: run-qunit.js URL');
phantom.exit(1);
}
page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main
// Phantom context (i.e. current "this")
page.onConsoleMessage = function (msg) {
console.log(msg);
};
page.open(system.args[1], function (status) {
if (status !== "success") {
console.log("Unable to access network");
phantom.exit(1);
}
waitFor(function () {
return page.evaluate(function () {
var el = document.getElementById('qunit-testresult');
if (el && el.innerText.match('completed')) {
return true;
}
return false;
});
}, function () {
var failedNum = page.evaluate(function () {
console.log("========================================================");
console.log(document.documentElement.innerHTML);
console.log("========================================================");
var el = document.getElementById('qunit-testresult');
console.log(el.innerText);
try {
return el.getElementsByClassName('failed')[0].innerHTML;
} catch (ignore) { }
return 10000;
});
phantom.exit((parseInt(failedNum, 10) > 0) ? 1 : 0);
});
});
}());
/*
* QtWebKit-powered headless test runner using PhantomJS
*
* PhantomJS binaries: http://phantomjs.org/download.html
* Requires PhantomJS 1.6+ (1.7+ recommended)
*
* Run with:
* phantomjs runner.js [url-of-your-qunit-testsuite]
*
* e.g.
* phantomjs runner.js http://localhost/qunit/test/index.html
*/
/*global phantom:false, require:false, console:false, window:false, QUnit:false */
(function() {
'use strict';
var url, page, timeout,
args = require('system').args;
// arg[0]: scriptName, args[1...]: arguments
if (args.length < 2 || args.length > 3) {
console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite] [timeout-in-seconds]');
phantom.exit(1);
}
url = args[1];
page = require('webpage').create();
if (args[2] !== undefined) {
timeout = parseInt(args[2], 10);
}
// Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`)
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.onInitialized = function() {
page.evaluate(addLogging);
};
page.onCallback = function(message) {
var result,
failed;
if (message) {
if (message.name === 'QUnit.done') {
result = message.data;
failed = !result || result.failed;
phantom.exit(failed ? 1 : 0);
}
}
};
page.open(url, function(status) {
if (status !== 'success') {
console.error('Unable to access network: ' + status);
phantom.exit(1);
} else {
// Cannot do this verification with the 'DOMContentLoaded' handler because it
// will be too late to attach it if a page does not have any script tags.
var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); });
if (qunitMissing) {
console.error('The `QUnit` object is not present on this page.');
phantom.exit(1);
}
// Set a timeout on the test running, otherwise tests with async problems will hang forever
if (typeof timeout === 'number') {
setTimeout(function() {
console.error('The specified timeout of ' + timeout + ' seconds has expired. Aborting...');
phantom.exit(1);
}, timeout * 1000);
}
// Do nothing... the callback mechanism will handle everything!
}
});
function addLogging() {
window.document.addEventListener('DOMContentLoaded', function() {
var currentTestAssertions = [];
QUnit.log(function(details) {
var response;
// Ignore passing assertions
if (details.result) {
return;
}
response = details.message || '';
if (typeof details.expected !== 'undefined') {
if (response) {
response += ', ';
}
response += 'expected: ' + details.expected + ', but was: ' + details.actual;
}
if (details.source) {
response += "\n" + details.source;
}
currentTestAssertions.push('Failed assertion: ' + response);
});
QUnit.testDone(function(result) {
var i,
len,
name = result.module + ': ' + result.name;
if (result.failed) {
console.log('Test failed: ' + name);
for (i = 0, len = currentTestAssertions.length; i < len; i++) {
console.log(' ' + currentTestAssertions[i]);
}
}
currentTestAssertions.length = 0;
});
QUnit.done(function(result) {
console.log('Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.');
if (typeof window.callPhantom === 'function') {
window.callPhantom({
'name': 'QUnit.done',
'data': result
});
}
});
}, false);
}
})();
Metadata-Version: 1.1
Name: test-launcher-for-officejs
Version: 0.0.4
Summary: only launch officejs test.
Home-page: http://j-io.org
Author: Sebastien Robin
Author-email: andrewjcarter@gmail.com
License: GPL
Description: UNKNOWN
Keywords: officejs test
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: GPL License
setup.py
test_launcher_for_officejs/__init__.py
test_launcher_for_officejs.egg-info/PKG-INFO
test_launcher_for_officejs.egg-info/SOURCES.txt
test_launcher_for_officejs.egg-info/dependency_links.txt
test_launcher_for_officejs.egg-info/top_level.txt
test_launcher_for_officejs/tests/__init__.py
test_launcher_for_officejs/tests/testOfficeJS.py
\ No newline at end of file
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from unittest import TestCase
import subprocess
class OFFICEJSTest(TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_01_officejs_without_requirejs(self):
"""
Launch officejs test without requirejs
"""
root_directory = __file__[0:-len("/test_launcher_for_officejs/tests/testOfficeJS.py")]
command = ["%s %s %s; exit 0" % (
'%s/node_modules/.bin/phantomjs' % root_directory,
'%s/test/run-qunit.js' % root_directory,
'%s/test/officejs.html' % root_directory)]
print command
result = subprocess.check_output(
command,
stderr=subprocess.STDOUT,
shell=True)
print result
self.assertTrue(result.find("assertions of")>=0)
# we should have string like 443 assertions of 444 passed, 1 failed.
total_quantity = 0
passed_quantity = 0
failed_quantity = 0
for line in result.split('\n'):
if line.find("assertions of") >=0:
splitted_line = line.split()
passed_quantity = splitted_line[0]
total_quantity = splitted_line[3]
failed_quantity = splitted_line[5]
self.assertTrue(total_quantity > 0)
print "\nOFFICEJS SUB RESULT: %s Tests, %s Failures" % (total_quantity,
failed_quantity)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment