diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c3695a..7acf5d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,23 +16,11 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Set up test environment - run: | - sudo apt-get update - sudo apt-get install xvfb gettext - wget https://github.com/mozilla/geckodriver/releases/download/v0.25.0/geckodriver-v0.25.0-linux64.tar.gz - mkdir geckodriver - tar -xzf geckodriver-v0.25.0-linux64.tar.gz -C geckodriver - export PATH=$PATH:$PWD/geckodriver - export BOKCHOY_HEADLESS=true - - - run: geckodriver --version - - name: Install Requirements run: | pip install -r requirements/ci.txt - name: Run Tests - run: xvfb-run --server-args=-ac -- tox -e ${{ matrix.toxenv }} env: - BOKCHOY_HEADLESS: true + TOXENV: ${{ matrix.toxenv }} + run: tox diff --git a/Makefile b/Makefile index 69d8800..0f229d2 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) pip-compile --upgrade -o requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in requirements/test.in requirements/travis.in pip-compile --upgrade -o requirements/quality.txt requirements/base.in requirements/quality.in requirements/test.in pip-compile --upgrade -o requirements/test.txt requirements/base.in requirements/test.in + pip-compile --upgrade -o requirements/travis.txt requirements/travis.in pip-compile --upgrade -o requirements/ci.txt requirements/ci.in # Let tox control the Django version for tests grep -e "^django==" requirements/test.txt > requirements/django.txt diff --git a/google_drive/tests/integration/base_test.py b/google_drive/tests/integration/base_test.py deleted file mode 100644 index f358605..0000000 --- a/google_drive/tests/integration/base_test.py +++ /dev/null @@ -1,20 +0,0 @@ -""" Base classes for integration tests """ -# -*- coding: utf-8 -*- -# - -# Imports ########################################################### -from __future__ import absolute_import -from xblockutils.base_test import SeleniumBaseTest - - -# Classes ########################################################### -class GoogleCalendarBaseTest(SeleniumBaseTest): # pylint: disable=too-few-public-methods - """ Base class for Google Calendar integration tests """ - module_name = __name__ - default_css_selector = 'div.google-calendar-xblock-wrapper' - - -class GoogleDocumentBaseTest(SeleniumBaseTest): # pylint: disable= too-few-public-methods - """ Base class for Google Document integration tests """ - module_name = __name__ - default_css_selector = 'div.google-docs-xblock-wrapper' diff --git a/google_drive/tests/integration/studio_scenarios.py b/google_drive/tests/integration/studio_scenarios.py deleted file mode 100644 index 59dd9b4..0000000 --- a/google_drive/tests/integration/studio_scenarios.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Contains a list of lists that will be used as the DDT arguments for the studio test. -""" -# -*- coding: utf-8 -*- -# - -# Constants ########################################################### -CALENDAR_SCENARIOS = [ - [ - 'Calendar', - ], -] - -DOCUMENT_SCENARIOS = [ - [ - 'Document', - ], -] - -IMAGE_SCENARIOS = [ - [ - 'Image', - ], -] diff --git a/google_drive/tests/integration/test_publish.py b/google_drive/tests/integration/test_publish.py deleted file mode 100644 index 38b4831..0000000 --- a/google_drive/tests/integration/test_publish.py +++ /dev/null @@ -1,46 +0,0 @@ -""" Runs tests for publish event functionality """ -# -*- coding: utf-8 -*- -# - -# Imports ########################################################### -from .base_test import GoogleCalendarBaseTest, GoogleDocumentBaseTest - - -# Classes ########################################################### -class GoogleCalendarPublishTestCase(GoogleCalendarBaseTest): - """ - Tests for Google Calendar event publishing functionality. - """ - - def test_calendar_publish_event(self): - """ Tests whether the publish event for calendar was triggered """ - calendar = self.go_to_page('Calendar') - load_event_complete = calendar.find_element_by_css_selector('.load_event_complete') - self.assertEqual( - load_event_complete.get_attribute('value'), - "I've published the event that indicates that the load has completed" - ) - - -class GoogleDocumentPublishTestCase(GoogleDocumentBaseTest): - """ - Tests for Google Document event publishing functionality. - """ - - def test_document_publish_event(self): - """ Tests whether the publish event for document was triggered """ - document = self.go_to_page('Document') - load_event_complete = document.find_element_by_css_selector('.load_event_complete') - self.assertEqual( - load_event_complete.get_attribute('value'), - "I've published the event that indicates that the load has completed" - ) - - def test_image_publish_event(self): - """ Tests whether the publish event for image was triggered """ - image = self.go_to_page('Image') - load_event_complete = image.find_element_by_css_selector('.load_event_complete') - self.assertEqual( - load_event_complete.get_attribute('value'), - "I've published the event that indicates that the load has completed" - ) diff --git a/google_drive/tests/integration/test_studio.py b/google_drive/tests/integration/test_studio.py deleted file mode 100644 index 7bf5293..0000000 --- a/google_drive/tests/integration/test_studio.py +++ /dev/null @@ -1,131 +0,0 @@ -""" Runs tests for the studio views """ -# -*- coding: utf-8 -*- -# - -# Imports ########################################################### -from __future__ import absolute_import -from ddt import data, ddt, unpack - -from google_drive.google_calendar import DEFAULT_CALENDAR_URL -from google_drive.google_docs import DEFAULT_DOCUMENT_URL -from google_drive.tests.test_const import TEST_IMAGE_URL - -from .base_test import GoogleCalendarBaseTest, GoogleDocumentBaseTest -from .studio_scenarios import CALENDAR_SCENARIOS, DOCUMENT_SCENARIOS, IMAGE_SCENARIOS - - -# Classes ########################################################### -@ddt # pylint: disable=too-many-ancestors -class GoogleCalendarStudioTest(GoogleCalendarBaseTest): # pylint: disable=too-many-ancestors - """ - Tests for Google Calendar studio view. - """ - default_css_selector = '#calendar-settings-tab' - - def studio_save(self): - """ Save changes made in studio for Google Calendar """ - self.browser.find_element_by_css_selector('#calendar-submit-options').click() - - @data(*CALENDAR_SCENARIOS) - @unpack - def test_save_calendar(self, page_name): - """ - Verify that option changes in Google Calendar studio view - are appropriately saved and visible immediately after - """ - self.go_to_page(page_name, view_name='studio_view') - # Expecting every input value to be valid - self.assertTrue(self.browser.find_element_by_css_selector('.validation_alert.covered')) - display_name_input = self.browser.find_element_by_css_selector('#edit_display_name') - # Change display name - display_name_input.clear() - display_name_input.send_keys('My Meetings') - calendar_id_input = self.browser.find_element_by_css_selector('#edit_calendar_id') - # Change calendar ID - calendar_id_input.clear() - calendar_id_input.send_keys('a') - self.wait_until_exists('#edit_calendar_id.error') - # Expects validation error due to calendar ID being invalid - self.assertTrue(self.browser.find_element_by_css_selector('.validation_alert:not(covered)')) - # Check to see that calendar ID input element is marked as invalid - self.assertTrue(self.browser.find_element_by_css_selector('#edit_calendar_id.error')) - # Save button should be disabled - self.assertTrue(self.browser.find_element_by_css_selector('#calendar-submit-options.disabled')) - clean_calendar_id_button = self.browser.find_element_by_css_selector('button.clear-calendar-id') - # Reset calendar ID value to default one - clean_calendar_id_button.click() - # Expecting every input value to be valid again - self.assertTrue(self.browser.find_element_by_css_selector('.validation_alert.covered')) - - self.studio_save() - self.go_to_page(page_name, css_selector='div.google-calendar-xblock-wrapper') - calendar_iframe = self.browser.find_element_by_css_selector('iframe') - # Expecting that default calendar is the one loaded in the IFrame - self.assertEqual(calendar_iframe.get_attribute("src"), DEFAULT_CALENDAR_URL) - # Expecting that the new display name is the title of the IFrame - self.assertEqual(calendar_iframe.get_attribute("title"), 'My Meetings') - - -@ddt -class GoogleDocumentStudioTest(GoogleDocumentBaseTest): - """ - Tests for Google Document studio view. - """ - default_css_selector = '#document-settings-tab' - - def studio_save(self): - """ Save changes made in studio for Google Document """ - self.browser.find_element_by_css_selector('#document-submit-options').click() - - @data(*DOCUMENT_SCENARIOS) - @unpack - def test_save_document(self, page_name): - """ - Verify that option changes in Google Document studio view - are appropriately saved and visible immediately after - """ - self.go_to_page(page_name, view_name='studio_view') - # Expecting every input value to be valid - self.assertTrue(self.browser.find_element_by_css_selector('.validation_alert.covered')) - display_name_input = self.browser.find_element_by_css_selector('#edit_display_name') - # Change display name - display_name_input.clear() - display_name_input.send_keys('My Document') - # Expecting list item that contains input element for alternative text to be hidden - self.assertTrue(self.browser.find_element_by_css_selector('li#alt_text_item.covered')) - - self.studio_save() - self.go_to_page(page_name, css_selector='div.google-docs-xblock-wrapper') - document_iframe = self.browser.find_element_by_css_selector('iframe') - # Expecting that default calendar is the one loaded in the IFrame - self.assertEqual(document_iframe.get_attribute("src"), DEFAULT_DOCUMENT_URL) - # Expecting that the new display name is the title of the IFrame - self.assertEqual(document_iframe.get_attribute("title"), 'My Document') - - @data(*IMAGE_SCENARIOS) - @unpack - def test_save_image(self, page_name): - """ - Verify that option changes in Google Image studio view - are appropriately saved and visible immediately after - """ - self.go_to_page(page_name, view_name='studio_view') - # Expecting every input value to be valid - self.assertTrue(self.browser.find_element_by_css_selector('.validation_alert.covered')) - display_name_input = self.browser.find_element_by_css_selector('#edit_display_name') - # Change display name - display_name_input.clear() - display_name_input.send_keys('My Image') - # Expecting list item that contains input element for alternative text to be shown - self.assertTrue(self.browser.find_element_by_css_selector('li#alt_text_item:not(covered)')) - alt_text_input = self.browser.find_element_by_css_selector('#edit_alt_text') - # Add alternative text for image - alt_text_input.send_keys('Alternative text for my image') - - self.studio_save() - self.go_to_page(page_name, css_selector='div.google-docs-xblock-wrapper') - image_iframe = self.browser.find_element_by_css_selector('img') - # Expecting that default calendar is the one loaded in the IFrame - self.assertEqual(image_iframe.get_attribute("src"), TEST_IMAGE_URL) - # Expecting that the new display name is the title of the IFrame - self.assertEqual(image_iframe.get_attribute("alt"), 'Alternative text for my image') diff --git a/requirements/dev.txt b/requirements/dev.txt index 53c48e0..105ea95 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -18,8 +18,6 @@ backports-functools-lru-cache==1.6.6 # via caniusepython3 binaryornot==0.4.4 # via cookiecutter -bok-choy==2.0.2 - # via -r requirements/test.in boto3==1.28.70 # via fs-s3fs botocore==1.31.70 @@ -60,7 +58,7 @@ coveralls==3.3.1 # via -r requirements/travis.in ddt==1.6.0 # via -r requirements/test.in -diff-cover==7.7.0 +diff-cover==8.0.0 # via -r requirements/dev.in distlib==0.3.7 # via @@ -119,9 +117,7 @@ jmespath==1.0.1 # boto3 # botocore lazy==1.6 - # via - # bok-choy - # xblock + # via xblock lazy-object-proxy==1.9.0 # via astroid lxml==4.9.3 @@ -246,8 +242,6 @@ rich==13.6.0 # via cookiecutter s3transfer==0.7.0 # via boto3 -selenium==3.141.0 - # via bok-choy simplejson==3.19.2 # via # xblock @@ -299,7 +293,6 @@ urllib3==1.26.18 # via # botocore # requests - # selenium # transifex-client virtualenv==20.24.6 # via tox diff --git a/requirements/quality.txt b/requirements/quality.txt index 3597ec2..6a6a12b 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -18,11 +18,9 @@ backports-functools-lru-cache==1.6.6 # via caniusepython3 binaryornot==0.4.4 # via cookiecutter -bok-choy==2.0.2 - # via -r requirements/test.in -boto3==1.28.70 +boto3==1.28.67 # via fs-s3fs -botocore==1.31.70 +botocore==1.31.67 # via # boto3 # s3transfer @@ -57,7 +55,7 @@ coverage[toml]==7.3.2 # pytest-cov ddt==1.6.0 # via -r requirements/test.in -diff-cover==7.7.0 +diff-cover==8.0.0 # via -r requirements/dev.in distlib==0.3.7 # via caniusepython3 @@ -105,9 +103,7 @@ jmespath==1.0.1 # boto3 # botocore lazy==1.6 - # via - # bok-choy - # xblock + # via xblock lazy-object-proxy==1.9.0 # via astroid lxml==4.9.3 @@ -219,8 +215,6 @@ rich==13.6.0 # via cookiecutter s3transfer==0.7.0 # via boto3 -selenium==3.141.0 - # via bok-choy simplejson==3.19.2 # via # xblock @@ -266,7 +260,6 @@ urllib3==1.26.18 # via # botocore # requests - # selenium # transifex-client web-fragments==2.1.0 # via diff --git a/requirements/test.in b/requirements/test.in index 8c6165d..7c1c6ec 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -3,7 +3,6 @@ -r dev.in -bok-choy ddt mock nose diff --git a/requirements/test.txt b/requirements/test.txt index 4cac431..bce426a 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -12,8 +12,6 @@ asgiref==3.7.2 # via django binaryornot==0.4.4 # via cookiecutter -bok-choy==2.0.2 - # via -r requirements/test.in boto3==1.28.70 # via fs-s3fs botocore==1.31.70 @@ -42,7 +40,7 @@ coverage[toml]==7.3.2 # pytest-cov ddt==1.6.0 # via -r requirements/test.in -diff-cover==7.7.0 +diff-cover==8.0.0 # via -r requirements/dev.in # via # -c requirements/common_constraints.txt @@ -80,9 +78,7 @@ jmespath==1.0.1 # boto3 # botocore lazy==1.6 - # via - # bok-choy - # xblock + # via xblock lxml==4.9.3 # via # xblock @@ -163,8 +159,6 @@ rich==13.6.0 # via cookiecutter s3transfer==0.7.0 # via boto3 -selenium==3.141.0 - # via bok-choy simplejson==3.19.2 # via # xblock @@ -201,7 +195,6 @@ urllib3==1.26.18 # via # botocore # requests - # selenium # transifex-client web-fragments==2.1.0 # via diff --git a/tox.ini b/tox.ini index 0e1d428..08f8d1f 100644 --- a/tox.ini +++ b/tox.ini @@ -22,8 +22,6 @@ deps = django32: Django>=3.2,<4.0 django42: Django>=4.2,<4.3 -r{toxinidir}/requirements/test.txt -passenv = - BOKCHOY_HEADLESS setenv = DJANGO_SETTINGS_MODULE = workbench.settings SCREENSHOT_DIR={toxinidir}/var/logs