class GetSubclassFromPOModuleTestCase(BaseTestCase):
    def setUp(self):
        super(GetSubclassFromPOModuleTestCase, self).setUp()
        self.p = BaseHomePage()

    @raises(exceptions.PageSelectionError)
    def test_no_fallback_raises_exception_with_nonexistent_package(self):
        klass = self.p.get_subclass_from_po_module("nonexistentpageobjects",
                                                   BaseResultsPage,
                                                   fallback_to_super=False)

    def test_with_fallback_with_nonexistent_package(self):
        klass = self.p.get_subclass_from_po_module("nonexistentpageobjects",
                                                   BaseResultsPage,
                                                   fallback_to_super=True)
        self.assertEqual(
            klass, BaseResultsPage,
            "Fallback with nonexistent package should fall back to class"
            "BaseSearchResultPage.")

    def test_package_on_path_with_fallback_succeeds(self):
        klass = self.p.get_subclass_from_po_module("mydbpageobjects",
                                                   BaseResultsPage,
                                                   fallback_to_super=True)
        self.assertEqual(klass.__name__, "MyDBResultsPage",
                         "MyDBResultsPage class should be selected.")

    def test_package_on_path_without_fallback_succeeds(self):
        klass = self.p.get_subclass_from_po_module("mydbpageobjects",
                                                   BaseResultsPage,
                                                   fallback_to_super=False)
        self.assertEqual(klass.__name__, "MyDBResultsPage",
                         "MyDBResultsPage class should be selected.")
class GetSubclassFromPOModuleTestCase(BaseTestCase):
    def setUp(self):
        super(GetSubclassFromPOModuleTestCase, self).setUp()
        self.p = BaseHomePage()

    @raises(exceptions.PageSelectionError)
    def test_no_fallback_raises_exception_with_nonexistent_package(self):
        klass = self.p.get_subclass_from_po_module("nonexistentpageobjects", BaseResultsPage, fallback_to_super=False)

    def test_with_fallback_with_nonexistent_package(self):
        klass = self.p.get_subclass_from_po_module("nonexistentpageobjects", BaseResultsPage, fallback_to_super=True)
        self.assertEqual(klass, BaseResultsPage, "Fallback with nonexistent package should fall back to class"
                                                      "BaseSearchResultPage.")

    def test_package_on_path_with_fallback_succeeds(self):
        klass = self.p.get_subclass_from_po_module("mydbpageobjects", BaseResultsPage, fallback_to_super=True)
        self.assertEqual(klass.__name__, "MyDBResultsPage", "MyDBResultsPage class should be selected.")

    def test_package_on_path_without_fallback_succeeds(self):
        klass = self.p.get_subclass_from_po_module("mydbpageobjects", BaseResultsPage, fallback_to_super=False)
        self.assertEqual(klass.__name__, "MyDBResultsPage", "MyDBResultsPage class should be selected.")
 def setUp(self):
     super(GetSubclassFromPOModuleTestCase, self).setUp()
     self.p = BaseHomePage()
Exemple #4
0
 def setUp(self):
     super(GetSubclassFromPOModuleTestCase, self).setUp()
     self.p = BaseHomePage()