From 80500768532e2707fd5f7f16d282cdaef4f05ee8 Mon Sep 17 00:00:00 2001 From: Abelardo Pardo Date: Sat, 22 Jun 2019 11:50:49 +1000 Subject: [PATCH] Adjustments to test to run with new code versions. --- src/action/tests/test_serializers.py | 2 +- src/ontask/tests/__init__.py | 0 src/table/tests/test_views.py | 5 +++ src/workflow/tests/test_views.py | 59 ++++++++++++++++------------ 4 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 src/ontask/tests/__init__.py diff --git a/src/action/tests/test_serializers.py b/src/action/tests/test_serializers.py index e10f41145..f6b53a24c 100644 --- a/src/action/tests/test_serializers.py +++ b/src/action/tests/test_serializers.py @@ -66,7 +66,7 @@ class ActionTestSerializers(test.OnTaskTestCase): "name": "age-2", "description_text": "", "data_type": "double", - "is_key": True, + "is_key": False, "position": 1, "in_viz": True, "categories": [], diff --git a/src/ontask/tests/__init__.py b/src/ontask/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/table/tests/test_views.py b/src/table/tests/test_views.py index e05a822da..5042fd271 100644 --- a/src/table/tests/test_views.py +++ b/src/table/tests/test_views.py @@ -511,6 +511,11 @@ def test_table_views(self): "//table[@id='view-table']//tr/td[1][normalize-space() = 'v1']/" "../td[3]/button[1]" ).click() + WebDriverWait(self.selenium, 10).until( + EC.element_to_be_clickable( + (By.XPATH, '//button[normalize-space()="Clone view"]') + ) + ) # Confirm view cloning self.selenium.find_element_by_xpath( "//div[@class='modal-footer']/button[normalize-space()='Clone " diff --git a/src/workflow/tests/test_views.py b/src/workflow/tests/test_views.py index 2e9224fb2..ed7743c08 100644 --- a/src/workflow/tests/test_views.py +++ b/src/workflow/tests/test_views.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import os -import test from django.conf import settings from selenium.webdriver.common.by import By @@ -9,6 +8,7 @@ from selenium.webdriver.support.ui import Select, WebDriverWait from dataops.pandas import db +import test from workflow.models import Workflow @@ -44,10 +44,11 @@ def test_01_workflow_create_upload_merge_column_edit(self): # Set the file name self.selenium.find_element_by_id('id_data_file').send_keys( - os.path.join(settings.BASE_DIR(), - 'workflow', - 'fixtures', - 'simple.csv') + os.path.join( + settings.BASE_DIR(), + 'workflow', + 'fixtures', + 'simple.csv') ) # Click on the NEXT button @@ -56,7 +57,7 @@ def test_01_workflow_create_upload_merge_column_edit(self): ).click() WebDriverWait(self.selenium, 10).until( EC.text_to_be_present_in_element((By.XPATH, "//body/div/h1"), - 'Select Columns') + 'Select Columns') ) # Change the name of one of the columns @@ -101,9 +102,9 @@ def test_01_workflow_create_upload_merge_column_edit(self): # Set the file name self.selenium.find_element_by_id('id_data_file').send_keys( os.path.join(settings.BASE_DIR(), - 'workflow', - 'fixtures', - 'simple2.csv') + 'workflow', + 'fixtures', + 'simple2.csv') ) # Click on the NEXT button @@ -112,7 +113,7 @@ def test_01_workflow_create_upload_merge_column_edit(self): ).click() WebDriverWait(self.selenium, 10).until( EC.text_to_be_present_in_element((By.XPATH, "//body/div/h1"), - 'Select Columns') + 'Select Columns') ) # Change the name of sid2 to sid @@ -197,10 +198,11 @@ def test_02_workflow_create_upload_with_prelude(self): # Set the file name self.selenium.find_element_by_id('id_data_file').send_keys( - os.path.join(settings.BASE_DIR(), - 'workflow', - 'fixtures', - 'csv_with_prelude_postlude.csv') + os.path.join( + settings.BASE_DIR(), + 'workflow', + 'fixtures', + 'csv_with_prelude_postlude.csv'), ) # Set the prelude to 6 lines and postlude to 3 self.selenium.find_element_by_id('id_skip_lines_at_top').clear() @@ -216,7 +218,7 @@ def test_02_workflow_create_upload_with_prelude(self): ).click() WebDriverWait(self.selenium, 10).until( EC.text_to_be_present_in_element((By.XPATH, "//body/div/h1"), - 'Select Columns') + 'Select Columns') ) WebDriverWait(self.selenium, 10).until_not( EC.visibility_of_element_located((By.ID, 'div-spinner')) @@ -368,7 +370,7 @@ def test_03_workflow_column_rename(self): # Select filter tab self.select_filter_tab() self.open_condition(None, - "//button[contains(@class, 'js-filter-create')]") + "//button[contains(@class, 'js-filter-create')]") # Select the another2 column (with new name select = Select(self.selenium.find_element_by_name( 'builder_rule_0_filter')) @@ -473,22 +475,27 @@ def test_workflow_attributes(self): '//table[@id="attribute-table"]' '//tr[2]/td[3]//button[contains(@class, "js-attribute-delete")]' ).click() + WebDriverWait(self.selenium, 10).until( + EC.element_to_be_clickable(( + By.XPATH, + '//div[@id="modal-item"]//div[@class="modal-footer"]/button')), + ) # Click in the delete confirm button self.selenium.find_element_by_xpath( - "//div[@id = 'modal-item']//div[@class = 'modal-footer']/button" + '//div[@id = "modal-item"]//div[@class = "modal-footer"]/button' ).click() # MODAL WAITING self.wait_for_page(element_id='workflow-detail') WebDriverWait(self.selenium, 10).until( EC.element_to_be_clickable( - (By.CLASS_NAME, "js-attribute-create") + (By.CLASS_NAME, 'js-attribute-create') ) ) # There should only be a single element self.assertEqual( len(self.selenium.find_elements_by_xpath( - "//table[@id='attribute-table']/tbody/tr" + '//table[@id="attribute-table"]/tbody/tr' )), 1 ) @@ -558,8 +565,8 @@ def test_workflow_share(self): # Value now should be in the table self.select_share_tab() self.search_table_row_by_string('share-table', - 1, - 'instructor02@bogus.com') + 1, + 'instructor02@bogus.com') # Click in the create share dialog again self.selenium.find_element_by_class_name('js-share-create').click() @@ -591,8 +598,8 @@ def test_workflow_share(self): # Value now should be in the table self.select_share_tab() self.search_table_row_by_string('share-table', - 1, - 'instructor02@bogus.com') + 1, + 'instructor02@bogus.com') # Check that the shared users are properly stored in the workflow workflow = Workflow.objects.all()[0] @@ -603,14 +610,14 @@ def test_workflow_share(self): # click the delete button in the superuser@bogus.com row element = self.search_table_row_by_string('share-table', - 1, - 'superuser@bogus.com') + 1, + 'superuser@bogus.com') element.find_element_by_xpath('td[2]/button').click() # Wait for the delete confirmation frame WebDriverWait(self.selenium, 10).until( EC.text_to_be_present_in_element((By.CLASS_NAME, 'modal-title'), - 'Confirm user deletion') + 'Confirm user deletion') ) # Click in the delete confirm button self.selenium.find_element_by_xpath(