From 703b6f612bca37df9f239ea9154aa5076ca1ad42 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Sat, 26 Sep 2015 15:55:33 -0700 Subject: [PATCH] Forgot to add some files for unit tests --- panoramix/bin/__init__.py | 0 run_tests.sh | 4 ++++ tests/__init__.py | 0 tests/core_tests.py | 42 ++++++++++++++++++++++++++++++++++ tests/panoramix_test_config.py | 6 +++++ 5 files changed, 52 insertions(+) create mode 100644 panoramix/bin/__init__.py create mode 100755 run_tests.sh create mode 100644 tests/__init__.py create mode 100644 tests/core_tests.py create mode 100644 tests/panoramix_test_config.py diff --git a/panoramix/bin/__init__.py b/panoramix/bin/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 000000000..47e9bb17d --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,4 @@ +rm /tmp/panoramix_unittests.db +export PANORAMIX_CONFIG=tests.panoramix_test_config +panoramix/bin/panoramix db upgrade +nosetests tests/core_tests.py --with-coverage --cover-package=panoramix diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/core_tests.py b/tests/core_tests.py new file mode 100644 index 000000000..244622dd5 --- /dev/null +++ b/tests/core_tests.py @@ -0,0 +1,42 @@ +import imp +import os +import unittest +import urllib2 +os.environ['PANORAMIX_CONFIG'] = 'tests.panoramix_test_config' +from flask.ext.testing import LiveServerTestCase, TestCase + +from panoramix import app, db, models +BASE_DIR = app.config.get("BASE_DIR") +cli = imp.load_source('cli', BASE_DIR + "/bin/panoramix") + + +class LiveTest(TestCase): + + def create_app(self): + app.config['LIVESERVER_PORT'] = 8873 + app.config['TESTING'] = True + return app + + def setUp(self): + print BASE_DIR + + def test_load_examples(self): + cli.load_examples(sample=True) + + def test_slices(self): + Slc = models.Slice + for slc in db.session.query(Slc).all(): + self.client.get(slc.slice_url) + viz = slc.viz + if hasattr(viz, 'get_json'): + self.client.get(viz.get_json()) + + def test_dashboard(self): + for dash in db.session.query(models.Dashboard).all(): + self.client.get(dash.url) + + def tearDown(self): + pass + +if __name__ == '__main__': + unittest.main() diff --git a/tests/panoramix_test_config.py b/tests/panoramix_test_config.py new file mode 100644 index 000000000..8001da98d --- /dev/null +++ b/tests/panoramix_test_config.py @@ -0,0 +1,6 @@ +from panoramix.config import * + +AUTH_USER_REGISTRATION_ROLE = 'alpha' +SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/panoramix_unittests.db' +DEBUG = True +PANORAMIX_WEBSERVER_PORT = 8081