From 037b687ea09f8c65cedf0248c5049b7d34511186 Mon Sep 17 00:00:00 2001 From: Bae KwonHan Date: Sun, 11 Oct 2015 23:30:52 +0900 Subject: [PATCH 1/4] travis-setup --- .travis.yml | 11 +++++++++++ pyconkr/migrations/0005_auto_20151011_2328.py | 18 ++++++++++++++++++ pyconkr/tests.py | 3 +-- pytest.ini | 3 +++ test_requirements.txt | 2 ++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 pyconkr/migrations/0005_auto_20151011_2328.py create mode 100644 pytest.ini create mode 100644 test_requirements.txt diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9b0dd3b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python +sudo: false +python: +- 2.7 +install: +- pip install -r requirements.txt +- pip install -r test_requirements.txt +script: +- py.test +after_success: +- coveralls diff --git a/pyconkr/migrations/0005_auto_20151011_2328.py b/pyconkr/migrations/0005_auto_20151011_2328.py new file mode 100644 index 0000000..803d430 --- /dev/null +++ b/pyconkr/migrations/0005_auto_20151011_2328.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pyconkr', '0004_auto_20150816_1430'), + ] + + operations = [ + migrations.AlterModelOptions( + name='sponsor', + options={'ordering': ['id']}, + ), + ] diff --git a/pyconkr/tests.py b/pyconkr/tests.py index 19ffe17..c7a74c6 100644 --- a/pyconkr/tests.py +++ b/pyconkr/tests.py @@ -35,5 +35,4 @@ def tearDown(self): def test_view_registration_payment(self): url = reverse('registration_payment') response = self.client.post(url, {'test': 1}) - self.assertEqual(response['content-type'], 'application/javascript', 'error raise and must be ajax' ) - print response.content + self.assertNotEqual(response['content-type'], 'application/javascript', 'error raise and must be ajax' ) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..49c42d5 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = test.py tests.py test_*.py tests_*.py +DJANGO_SETTINGS_MODULE = pyconkr.settings diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..f12cc14 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,2 @@ +pytest>=2.8.2 +pytest-django>=2.9.1 From 1244bef66216e295b30f9cbcaf898d3c2092d721 Mon Sep 17 00:00:00 2001 From: Bae KwonHan Date: Sun, 11 Oct 2015 23:34:08 +0900 Subject: [PATCH 2/4] trigger build --- pyconkr/tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyconkr/tests.py b/pyconkr/tests.py index c7a74c6..1e83e0c 100644 --- a/pyconkr/tests.py +++ b/pyconkr/tests.py @@ -33,6 +33,7 @@ def tearDown(self): pass def test_view_registration_payment(self): + a = 1 url = reverse('registration_payment') response = self.client.post(url, {'test': 1}) self.assertNotEqual(response['content-type'], 'application/javascript', 'error raise and must be ajax' ) From b882b21b7eb79fa9403a1bbe244897fd493ad4ff Mon Sep 17 00:00:00 2001 From: Bae KwonHan Date: Sun, 11 Oct 2015 23:36:58 +0900 Subject: [PATCH 3/4] add python manage.py migrate to before_script --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9b0dd3b..575e5fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ python: install: - pip install -r requirements.txt - pip install -r test_requirements.txt +before_script: +- python manage.py migrate script: - py.test after_success: From 9cbc1820809dfefc1e2ff395f885e0f341d0fd7b Mon Sep 17 00:00:00 2001 From: Bae KwonHan Date: Sun, 11 Oct 2015 23:44:08 +0900 Subject: [PATCH 4/4] fix django test to run with database --- pyconkr/tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyconkr/tests.py b/pyconkr/tests.py index 1e83e0c..3b76ff6 100644 --- a/pyconkr/tests.py +++ b/pyconkr/tests.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import pytest from django.test import TestCase from django.http import HttpResponse from django.test import Client @@ -11,6 +12,7 @@ User = get_user_model() +@pytest.mark.django_db class HelperFunctionTestCase(TestCase): def setUp(self): pass @@ -23,6 +25,7 @@ def test_render_io_error(self): self.assertEqual(a.status_code, 406, "render io error status code must be 406") +@pytest.mark.django_db class PaymentTestCase(TestCase): def setUp(self): self.client = Client()