From 39fb2287fd2ccd8bcc4973bc5d0964b548f46837 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 14:30:54 +0200 Subject: [PATCH 01/14] [#2216] Add runserver to .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b2d8b48731..8d9a409ce4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ install: before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres + - python manage.py runserver script: - python manage.py test akvo.rsr.tests.iati_import From 43e7090883847a4f5ce53840ecfbaae3ce3c384e Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 14:37:43 +0200 Subject: [PATCH 02/14] [#2216] Add migrations and & after runserver --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8d9a409ce4..f857c29566 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,8 @@ install: before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres - - python manage.py runserver + - python manage.py migrate rsr --noinput + - python manage.py runserver & script: - python manage.py test akvo.rsr.tests.iati_import From e090e81bd292549b3d37681a66e0d3625a56a491 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 15:28:20 +0200 Subject: [PATCH 03/14] [#2216] Run all tests in Travis and Coveralls --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f857c29566..37933b24ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,12 +22,11 @@ install: before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres - - python manage.py migrate rsr --noinput - python manage.py runserver & script: - - python manage.py test akvo.rsr.tests.iati_import - - coverage run --source=akvo manage.py test akvo.rsr.tests.iati_import + - python manage.py test akvo.rsr.tests + - coverage run --source=akvo manage.py test akvo.rsr.tests after_success: - coveralls From 1d2c236ee84bf54cfc26e63d4b083f0ad95c4dd8 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:06:34 +0200 Subject: [PATCH 04/14] [#2216] Re-add yuglify and collectstatic to .travis.yml --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 37933b24ce..b2d8b26712 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_install: - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ install: + - npm install -g yuglify - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls @@ -25,7 +26,8 @@ before_script: - python manage.py runserver & script: - - python manage.py test akvo.rsr.tests + - python manage.py collectstatic --noinput + - python manage.py test --noinput akvo.rsr.tests - coverage run --source=akvo manage.py test akvo.rsr.tests after_success: From 881392145c8bdaf04b7d83da5ceaa4a1663720d9 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:17:26 +0200 Subject: [PATCH 05/14] [#2216] Install yuglify in /usr --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b2d8b26712..d1eaf165e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_install: - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ install: + - npm set prefix /usr - npm install -g yuglify - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls From 6212f4c4d8e151ea3868e4405da4ece7125a303d Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:20:42 +0200 Subject: [PATCH 06/14] [#2216] Install yuglify in /usr (with sudo) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d1eaf165e5..95b8849ae9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,10 @@ before_install: - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ install: - - npm set prefix /usr - - npm install -g yuglify - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls + - npm set prefix /usr + - sudo npm install -g yuglify before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres From 21ffe1be8758aefa52042cf474fe6097a5cce12d Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:41:41 +0200 Subject: [PATCH 07/14] [#2216] Install yuglify in /usr (different way) --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95b8849ae9..d05fa038ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,9 @@ before_install: - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ install: + - sudo npm install yuglify -g --prefix /usr - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls - - npm set prefix /usr - - sudo npm install -g yuglify before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres From e6c72f1a7bfe4c202c22f49afe517bfdd0ac910d Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:45:02 +0200 Subject: [PATCH 08/14] [#2216] Install yuglify in /usr (different way again) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d05fa038ac..8698e6df47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ install: - - sudo npm install yuglify -g --prefix /usr + - npm install yuglify -g --prefix /usr - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls From c33f73950693883173da61eb36e6c0b270be29ed Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:49:49 +0200 Subject: [PATCH 09/14] [#2216] Make /usr/lib/node_modules folder --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8698e6df47..21b1da3879 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ before_install: - sudo mkdir /var/log/akvo/ && sudo chmod -R 777 /var/log/akvo/ - sudo mkdir /var/akvo/ && sudo chmod -R 777 /var/akvo/ - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ + - sudo mkdir /usr/lib/node_modules && sudo chmod -R 777 /usr/lib/node_modules install: - npm install yuglify -g --prefix /usr From d6dc2a6a8e04bc2fe49719cd2dcf9b375f8c3c7c Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Wed, 8 Jun 2016 16:54:17 +0200 Subject: [PATCH 10/14] [#2216] Add /home/travis/.nvm/v0.10.36/bin/npm/yuglify to PATH in Travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21b1da3879..611b01d5c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,12 @@ before_install: - sudo mkdir /var/log/akvo/ && sudo chmod -R 777 /var/log/akvo/ - sudo mkdir /var/akvo/ && sudo chmod -R 777 /var/akvo/ - sudo mkdir /var/www/ && sudo chmod -R 777 /var/www/ - - sudo mkdir /usr/lib/node_modules && sudo chmod -R 777 /usr/lib/node_modules install: - - npm install yuglify -g --prefix /usr - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls + - npm install -g yuglify + - export PATH=$PATH:/home/travis/.nvm/v0.10.36/bin/npm/yuglify before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres From 3f09aeb2024c5b4a573ec8b5fb0003bff746f3ad Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Tue, 21 Jun 2016 12:29:00 +0200 Subject: [PATCH 11/14] [#2216] Remove yuglify installation --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 611b01d5c8..a11538a704 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,6 @@ before_install: install: - pip install -r scripts/deployment/pip/requirements/2_rsr.txt - pip install coveralls - - npm install -g yuglify - - export PATH=$PATH:/home/travis/.nvm/v0.10.36/bin/npm/yuglify before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres From 899059faee482aafca2f5fa62a42c2eca534d7c3 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Tue, 21 Jun 2016 12:43:24 +0200 Subject: [PATCH 12/14] [#2216] Disable pipeline for Travis and run migrations --- .travis.yml | 1 + akvo/settings/80-travis.conf | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a11538a704..79ed17804a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ install: before_script: - psql -c 'CREATE DATABASE travis_test;' -U postgres + - python manage.py migrate --noinput - python manage.py runserver & script: diff --git a/akvo/settings/80-travis.conf b/akvo/settings/80-travis.conf index b01dc136e5..74f4d4b0d5 100644 --- a/akvo/settings/80-travis.conf +++ b/akvo/settings/80-travis.conf @@ -1,6 +1,9 @@ import os if 'TRAVIS' in os.environ: + STATICFILES_STORAGE='pipeline.storage.NonPackagingPipelineStorage' + PIPELINE_ENABLED=False + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', From dbc90973bd2849d5fa48a773a3b54114e9ae6c61 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Tue, 21 Jun 2016 13:49:42 +0200 Subject: [PATCH 13/14] [#2216] Comment out test_valid_xml test --- .../rsr/tests/iati_export/test_iati_export.py | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/akvo/rsr/tests/iati_export/test_iati_export.py b/akvo/rsr/tests/iati_export/test_iati_export.py index c6c49d84f3..8c7f8993d1 100644 --- a/akvo/rsr/tests/iati_export/test_iati_export.py +++ b/akvo/rsr/tests/iati_export/test_iati_export.py @@ -82,36 +82,36 @@ def test_status(self): # Test if status is set to completed. self.assertEqual(iati_export.status, 3) - def test_valid_xml(self): - """ - - Test if the export has an XML file. - - Test if the XML is valid. - """ - - # Retrieve the latest IATI export - iati_export = IatiExport.objects.order_by('-id').first() - - # Test if export has an XML file - self.assertNotEqual(iati_export.iati_file, '') - - # Get XML string of file - tree = ElementTree.parse(iati_export.iati_file) - root = tree.getroot() - root_tostring = ElementTree.tostring(root, encoding='utf8', method='xml') - - # Test if XML is valid - root_test = self.assertXmlDocument(root_tostring) - - # Test if the root's tag name is 'iati-activities' - self.assertXmlNode(root_test, tag='iati-activities') - - # Test if the root has attributes 'generated-datetime' and 'version' - self.assertXmlHasAttribute(root_test, 'generated-datetime') - self.assertXmlHasAttribute(root_test, 'version') - - # Test if the root has correct child nodes: 'iati-activity' with an 'iati-identifier', - # 'reporting-org' and 'title' - self.assertXpathsExist(root_test, ('./iati-activity', - './iati-activity/iati-identifier', - './iati-activity/reporting-org', - './iati-activity/title')) + # def test_valid_xml(self): + # """ + # - Test if the export has an XML file. + # - Test if the XML is valid. + # """ + # + # # Retrieve the latest IATI export + # iati_export = IatiExport.objects.order_by('-id').first() + # + # # Test if export has an XML file + # self.assertNotEqual(iati_export.iati_file, '') + # + # # Get XML string of file + # tree = ElementTree.parse(iati_export.iati_file) + # root = tree.getroot() + # root_tostring = ElementTree.tostring(root, encoding='utf8', method='xml') + # + # # Test if XML is valid + # root_test = self.assertXmlDocument(root_tostring) + # + # # Test if the root's tag name is 'iati-activities' + # self.assertXmlNode(root_test, tag='iati-activities') + # + # # Test if the root has attributes 'generated-datetime' and 'version' + # self.assertXmlHasAttribute(root_test, 'generated-datetime') + # self.assertXmlHasAttribute(root_test, 'version') + # + # # Test if the root has correct child nodes: 'iati-activity' with an 'iati-identifier', + # # 'reporting-org' and 'title' + # self.assertXpathsExist(root_test, ('./iati-activity', + # './iati-activity/iati-identifier', + # './iati-activity/reporting-org', + # './iati-activity/title')) From 4613f1ef7d3660a5088de48fdb34c9ba30d317fe Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Tue, 21 Jun 2016 14:35:18 +0200 Subject: [PATCH 14/14] [#2216] Fix test_valid_xml test --- .../rsr/tests/iati_export/test_iati_export.py | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/akvo/rsr/tests/iati_export/test_iati_export.py b/akvo/rsr/tests/iati_export/test_iati_export.py index 8c7f8993d1..2fae2fdf2c 100644 --- a/akvo/rsr/tests/iati_export/test_iati_export.py +++ b/akvo/rsr/tests/iati_export/test_iati_export.py @@ -82,36 +82,36 @@ def test_status(self): # Test if status is set to completed. self.assertEqual(iati_export.status, 3) - # def test_valid_xml(self): - # """ - # - Test if the export has an XML file. - # - Test if the XML is valid. - # """ - # - # # Retrieve the latest IATI export - # iati_export = IatiExport.objects.order_by('-id').first() - # - # # Test if export has an XML file - # self.assertNotEqual(iati_export.iati_file, '') - # - # # Get XML string of file - # tree = ElementTree.parse(iati_export.iati_file) - # root = tree.getroot() - # root_tostring = ElementTree.tostring(root, encoding='utf8', method='xml') - # - # # Test if XML is valid - # root_test = self.assertXmlDocument(root_tostring) - # - # # Test if the root's tag name is 'iati-activities' - # self.assertXmlNode(root_test, tag='iati-activities') - # - # # Test if the root has attributes 'generated-datetime' and 'version' - # self.assertXmlHasAttribute(root_test, 'generated-datetime') - # self.assertXmlHasAttribute(root_test, 'version') - # - # # Test if the root has correct child nodes: 'iati-activity' with an 'iati-identifier', - # # 'reporting-org' and 'title' - # self.assertXpathsExist(root_test, ('./iati-activity', - # './iati-activity/iati-identifier', - # './iati-activity/reporting-org', - # './iati-activity/title')) + def test_valid_xml(self): + """ + - Test if the export has an XML file. + - Test if the XML is valid. + """ + + # Retrieve the latest IATI export + iati_export = IatiExport.objects.order_by('-id').first() + + # Test if export has an XML file + self.assertNotEqual(iati_export.iati_file, '') + + # Get XML string of file + tree = ElementTree.parse(iati_export.iati_file.file) + root = tree.getroot() + root_tostring = ElementTree.tostring(root, encoding='utf8', method='xml') + + # Test if XML is valid + root_test = self.assertXmlDocument(root_tostring) + + # Test if the root's tag name is 'iati-activities' + self.assertXmlNode(root_test, tag='iati-activities') + + # Test if the root has attributes 'generated-datetime' and 'version' + self.assertXmlHasAttribute(root_test, 'generated-datetime') + self.assertXmlHasAttribute(root_test, 'version') + + # Test if the root has correct child nodes: 'iati-activity' with an 'iati-identifier', + # 'reporting-org' and 'title' + self.assertXpathsExist(root_test, ('./iati-activity', + './iati-activity/iati-identifier', + './iati-activity/reporting-org', + './iati-activity/title'))