From f23d6d957de61d0ea287f7617532e6399a505b71 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Fri, 28 Aug 2015 15:28:14 +0300 Subject: [PATCH] Minor refactoring of integration tests Simplify 2 CheckBoxRegion-s by moving their common functionality into mixin. Change-Id: I0cc137702ff408aeb7af433c56c87aba091b8dc6 --- .../test/integration_tests/regions/forms.py | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/openstack_dashboard/test/integration_tests/regions/forms.py b/openstack_dashboard/test/integration_tests/regions/forms.py index ab0e3b87ab..d24453d04d 100644 --- a/openstack_dashboard/test/integration_tests/regions/forms.py +++ b/openstack_dashboard/test/integration_tests/regions/forms.py @@ -76,41 +76,32 @@ class BaseFormFieldRegion(baseregion.BaseRegion): return self.element.is_displayed() -class CheckBoxFormFieldRegion(BaseFormFieldRegion): +class CheckBoxMixin(object): + def is_marked(self): + return self.element.is_selected() + + def mark(self): + if not self.is_marked(): + self.element.click() + + def unmark(self): + if self.is_marked(): + self.element.click() + + +class CheckBoxFormFieldRegion(BaseFormFieldRegion, CheckBoxMixin): """Checkbox field.""" _element_locator = (by.By.CSS_SELECTOR, 'div > label > input[type=checkbox]') - def is_marked(self): - return self.element.is_selected() - def mark(self): - if not self.is_marked(): - self.element.click() - - def unmark(self): - if self.is_marked(): - self.element.click() - - -class ProjectPageCheckBoxFormFieldRegion(BaseFormFieldRegion): +class ProjectPageCheckBoxFormFieldRegion(BaseFormFieldRegion, CheckBoxMixin): """Checkbox field for Project-page.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=checkbox]') - def is_marked(self): - return self.element.is_selected() - - def mark(self): - if not self.is_marked(): - self.element.click() - - def unmark(self): - if self.is_marked(): - self.element.click() - class ChooseFileFormFieldRegion(BaseFormFieldRegion): """Choose file field."""