Public bug reported:

The integration test has a function called 'is_the_page_title' which checks the 
title of current page with title assigned for each page on horizon like Login 
page has its own title etc.
The comparison and raising of AssertionError when title doesnt meet actual page 
title , can be easily replaced with unittest built-in function 'assertIn( str1, 
str2, msg ) as follows:
 ORIGINAL:
    def is_the_current_page(self):
        if self._page_title not in self.page_title:
            raise AssertionError(
                "Expected to find %s in page title, instead found: %s"
                % (self._page_title, self.page_title))

PROPOSED :
    def is_the_current_page(self):
       self.assertIn(title, self.page_title,
            "Expected to find %s in page title, instead found: %s"
                % (self._page_title, self.page_title))

The source code for the specific function is here :
https://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/test/integration_tests/pages/pageobject.py

** Affects: horizon
     Importance: Undecided
         Status: New


** Tags: integration-tests low-hanging-fruit

** Description changed:

- The integration test has a function called 'is_the_page_title' which checks 
the title of current page with title assigned for each page on horizon like 
Login page has its own title etc. 
+ The integration test has a function called 'is_the_page_title' which checks 
the title of current page with title assigned for each page on horizon like 
Login page has its own title etc.
  The comparison and raising of AssertionError when title doesnt meet actual 
page title , can be easily replaced with unittest built-in function 'assertIn( 
str1, str2, msg ) as follows:
-  ORIGINAL:
-     def is_the_current_page(self):
-         if self._page_title not in self.page_title:
-             raise AssertionError(
-                 "Expected to find %s in page title, instead found: %s"
-                 % (self._page_title, self.page_title))
+  ORIGINAL:
+     def is_the_current_page(self):
+         if self._page_title not in self.page_title:
+             raise AssertionError(
+                 "Expected to find %s in page title, instead found: %s"
+                 % (self._page_title, self.page_title))
  
  PROPOSED :
-     def is_the_current_page(self):
-        self.assertIn(title, self.page_title,
-             "Expected to find %s in page title, instead found: %s"
-                 % (title, self.page_title))
+     def is_the_current_page(self):
+        self.assertIn(title, self.page_title,
+             "Expected to find %s in page title, instead found: %s"
+                 % (self._page_title, self.page_title))
  
  The source code for the specific function is here :
  
https://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/test/integration_tests/pages/pageobject.py

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1403268

Title:
  Replace 'raise AssertionError' in integration tests with
  'self.assertIn'

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
  The integration test has a function called 'is_the_page_title' which checks 
the title of current page with title assigned for each page on horizon like 
Login page has its own title etc.
  The comparison and raising of AssertionError when title doesnt meet actual 
page title , can be easily replaced with unittest built-in function 'assertIn( 
str1, str2, msg ) as follows:
   ORIGINAL:
      def is_the_current_page(self):
          if self._page_title not in self.page_title:
              raise AssertionError(
                  "Expected to find %s in page title, instead found: %s"
                  % (self._page_title, self.page_title))

  PROPOSED :
      def is_the_current_page(self):
         self.assertIn(title, self.page_title,
              "Expected to find %s in page title, instead found: %s"
                  % (self._page_title, self.page_title))

  The source code for the specific function is here :
  
https://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/test/integration_tests/pages/pageobject.py

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1403268/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to