From bc850d0a0c4af535ed9164998d2442233056258b Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Sun, 31 May 2015 15:34:51 -0400 Subject: [PATCH] travis tests --- .travis.yml | 17 +++++++++++++++++ tests/test_project.py | 17 ++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c50f106 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: python +env: + - DJANGO_SETTINGS_MODULE= + - DJANGO_VERSION=1.6 + - DJANGO_VERSION=1.7 + - DJANGO_VERSION=1.8 +python: + - "2.7" + - "3.3" + - "3.4" +# command to install dependencies +install: + - pip install -q Django==$DJANGO_VERSION + - pip install -q . + - pip install -q -r requirements.txt +# command to run tests +script: nosetests tests diff --git a/tests/test_project.py b/tests/test_project.py index 5393bb8..f6c464a 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -13,6 +13,9 @@ PYTHON_INTERPRETTER = 'python' DJANGUI_PROCESS = None CELERY_PROCESS = None +env = os.environ +env['DJANGO_SETTINGS_MODULE'] = '{}.settings'.format(DJANGUI_TEST_PROJECT_NAME) + class TestProject(TestCase): def setUp(self): # start the project @@ -21,10 +24,10 @@ class TestProject(TestCase): shutil.rmtree(DJANGUI_TEST_PROJECT_PATH) global DJANGUI_PROCESS global CELERY_PROCESS - proc = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_SCRIPT_PATH, '-p', DJANGUI_TEST_PROJECT_NAME], cwd=BASE_DIR) + proc = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_SCRIPT_PATH, '-p', DJANGUI_TEST_PROJECT_NAME], cwd=BASE_DIR, env=env) proc.wait() - DJANGUI_PROCESS = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_TEST_PROJECT_MANAGE, 'runserver']) - CELERY_PROCESS = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_TEST_PROJECT_MANAGE, 'celery', 'worker']) + DJANGUI_PROCESS = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_TEST_PROJECT_MANAGE, 'runserver'], env=env) + CELERY_PROCESS = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_TEST_PROJECT_MANAGE, 'celery', 'worker'], env=env) def tearDown(self): global DJANGUI_PROCESS @@ -33,5 +36,9 @@ class TestProject(TestCase): CELERY_PROCESS.kill() shutil.rmtree(DJANGUI_TEST_PROJECT_PATH) - def test_simple(self): - assert(True) == True + def test_project(self): + # TODO: this is a hack, figure out a better way to do an integrated test + proc = subprocess.Popen([PYTHON_INTERPRETTER, DJANGUI_TEST_PROJECT_MANAGE, 'test', 'djangui.tests'], + env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = proc.communicate() + assert ('ok' in stderr.lower()) is True, stderr \ No newline at end of file