From 90864369c0a8ac9059273c65f67de812c49a209a Mon Sep 17 00:00:00 2001 From: vintorez Date: Sun, 12 Oct 2014 12:02:17 +0400 Subject: [PATCH] =?UTF-8?q?Technical=20Debt=20#2257=20=D0=9D=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B8=D1=82=D1=8C=20Travis=20CI.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Необходимо настроить Travis CI на работу с селениум-тестами. --- .travis.yml | 9 +++++++-- exmo/core/test_utils.py | 8 ++++---- exmo/exmo/settings.py | 7 ++++++- exmo/monitorings/test_selenium.py | 12 ++++++------ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9f7d1f5..7ed9ff6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,10 @@ language: python python: - "2.7" -install: "pip install -r exmo/requirements.txt" -script: cd exmo && ./manage.py test +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" +install: + - "pip install -r exmo/requirements.txt" +script: + - "cd exmo && ./manage.py test" diff --git a/exmo/core/test_utils.py b/exmo/core/test_utils.py index fd39aece..d92eb76a 100644 --- a/exmo/core/test_utils.py +++ b/exmo/core/test_utils.py @@ -59,7 +59,7 @@ def setUpClass(cls): if not getattr(cls, '__unittest_skip__', False): webdriver_type = getattr(settings, 'SELENIUM_WEBDRIVER', 'FALLBACK') if webdriver_type == 'FALLBACK': - for webdriver_type in 'PhantomJS Firefox Chrome Opera'.split(): + for webdriver_type in 'Firefox PhantomJS Chrome Opera'.split(): try: cls.webdrv = getattr(webdriver, webdriver_type)() except Exception: @@ -90,9 +90,9 @@ def findall(self, selector): def _assertWebElementMethod(self, selector, method, expected_result, wait_timeout=TIMEOUT): def condition(*args): - element = self.find(selector) - if element: - return method(element) == expected_result + elements = self.findall(selector) + if elements: + return all(item == expected_result for item in map(method, elements)) WebDriverWait(self.webdrv, wait_timeout).until(condition) def assertVisible(self, selector, wait_timeout=TIMEOUT): diff --git a/exmo/exmo/settings.py b/exmo/exmo/settings.py index 9513687c..6f364fa8 100644 --- a/exmo/exmo/settings.py +++ b/exmo/exmo/settings.py @@ -87,6 +87,11 @@ 'django.contrib.auth.hashers.MD5PasswordHasher', ) + import logging + logging.getLogger('south').setLevel(logging.WARNING) + logging.getLogger('configuration').setLevel(logging.WARNING) + logging.getLogger('selenium.webdriver.remote.remote_connection').setLevel(logging.WARNING) + TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' # A secret key for this particular Django installation. Used in secret-key hashing algorithms. @@ -108,7 +113,7 @@ USE_I18N = True # MODELTRANSLATION_FALLBACK_LANGUAGES will be used as fallback language if some model does not -# have transalted field to other language. +# have translated field to other language. MODELTRANSLATION_FALLBACK_LANGUAGES = ('en', 'ru', 'ka', 'az') USE_ETAGS = True diff --git a/exmo/monitorings/test_selenium.py b/exmo/monitorings/test_selenium.py index 728541ff..7c360837 100644 --- a/exmo/monitorings/test_selenium.py +++ b/exmo/monitorings/test_selenium.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -from django.contrib.auth.models import Group, User +from django.contrib.auth.models import User from django.core.urlresolvers import reverse from model_mommy import mommy from nose.plugins.attrib import attr @@ -29,17 +29,17 @@ @attr('selenium') class OpennessInitialColumnTestCase(BaseSeleniumTestCase): - # Scenario: Check if initial openness column is display + # Check if initial openness column is display modal_window = '.modal-open' init_openness = '.init-openness' def setUp(self): # GIVEN expert B account - expertB = User.objects.create_user('expertB', 'expertB@svobodainfo.org', 'password') + expertB = User.objects.create_user('expertB', 'usr@svobodainfo.org', 'password') expertB.profile.is_expertB = True # AND published monitoring self.monitoring = mommy.make(Monitoring, status=MONITORING_PUBLISHED) - # AND organzation at this monitoring + # AND organization at this monitoring self.organization = mommy.make(Organization, monitoring=self.monitoring) # AND task for expert B self.task = mommy.make( @@ -75,12 +75,12 @@ def test_users(self): self.find(self.modal_window).click() # THEN checkboxes should become visible self.assertVisible('#id_rt_initial_openness') - # WHEN i click initial openness checkbox + # WHEN I click initial openness checkbox self.find('#id_rt_initial_openness').click() # AND submit my changes self.find('#modal_window input[type="submit"]').click() # THEN initial openness column should be displayed - self.assertEqual(self.find(self.init_openness).is_displayed(), True) + self.assertVisible(self.init_openness) @attr('selenium')