diff --git a/tests/scenarios/test_location_should_be_for_absolute_path.py b/tests/scenarios/test_location_should_be_for_absolute_path.py index ecf1be0..c3e6446 100755 --- a/tests/scenarios/test_location_should_be_for_absolute_path.py +++ b/tests/scenarios/test_location_should_be_for_absolute_path.py @@ -1,18 +1,20 @@ -from po.ncbi import NCBIPage import unittest import os +from robotpageobjects import Page class BaseMethodLocationShouldBeTestCase2(unittest.TestCase): + baseurl = "file://%s" % os.path.join(os.path.dirname(os.path.realpath(__file__)), "site") def test_location_should_be_for_absolute_path(self): - os.environ["PO_BASEURL"] = "http://www.ncbi.nlm.nih.gov" - self.p = NCBIPage() - self.p.open({"path": "pubmed"}) - self.p.location_should_be("http://www.ncbi.nlm.nih.gov/pubmed") + os.environ["PO_BASEURL"] = self.baseurl + Page.uri = "/index.html" + self.p = Page() + self.p.open() + self.p.location_should_be(os.path.join(self.baseurl, "index.html")) def tearDown(self): self.p.close() if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/tests/scenarios/test_location_should_be_for_relative_path.py b/tests/scenarios/test_location_should_be_for_relative_path.py index f0b1d49..df91856 100755 --- a/tests/scenarios/test_location_should_be_for_relative_path.py +++ b/tests/scenarios/test_location_should_be_for_relative_path.py @@ -1,17 +1,21 @@ from po.ncbi import NCBIPage import unittest import os - +from robotpageobjects import Page class BaseMethodLocationShouldBeTestCase(unittest.TestCase): + + baseurl = "file://%s" % os.path.join(os.path.dirname(os.path.realpath(__file__)), "site") + def test_location_should_be_for_relative_path(self): - os.environ["PO_BASEURL"] = "http://www.ncbi.nlm.nih.gov" - self.p = NCBIPage() - self.p.open({"path": "pubmed"}) - self.p.location_should_be("/pubmed") + os.environ["PO_BASEURL"] = self.baseurl + Page.uri = "/index.html" + self.p = Page() + self.p.open() + self.p.location_should_be("/index.html") def tearDown(self): self.p.close() if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/tests/scenarios/test_service_args_cookie_file.py b/tests/scenarios/test_service_args_cookie_file.py deleted file mode 100755 index 675e1cd..0000000 --- a/tests/scenarios/test_service_args_cookie_file.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest -from po import selectors_page -from robotpageobjects import base -import time - -class ServiceArgsCookieFileTestCase(unittest.TestCase): - - def test_open_close_creates_cookie_file(self): - self.p = selectors_page.Page() - self.p.open() - self.p.close() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_functional.py b/tests/test_functional.py index f00acc2..511feff 100755 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -463,34 +463,6 @@ def test_wait_till_element_disappears(self): run = self.run_scenario("test_wait_until_not_visible.py") self.assert_run(run, expected_returncode=0) -class ServiceArgsTestCase(BaseTestCase): - cookies_file_name = "service-args-cookies.txt" - - def _remove_file_if_exists(self, file_path): - try: - os.remove(file_path) - except OSError: - pass - - def setUp(self): - self.cookies_file_path = os.path.join(self.scenario_dir, self.cookies_file_name) - self._remove_file_if_exists(self.cookies_file_path) - - - def test_can_set_service_args(self): - self.set_baseurl_env() - - # Use the cookies-file argument to PhantomJS as a test for PO_SERVICE_ARGS. - run = self.run_scenario("test_service_args_cookie_file.py", env={"PO_SERVICE_ARGS": "--cookies-file=%s" % self.cookies_file_path}) - - # Assert that the test passed and that the file exists. - self.assert_run(run, expected_returncode=0) - self.assertTrue(os.path.isfile(self.cookies_file_path), "File %s specified as cookies-file in service_args does not exist." % self.cookies_file_name) - - def tearDown(self): - self._remove_file_if_exists(self.cookies_file_path) - - class LoggingTestCase(BaseTestCase): """ @@ -621,4 +593,4 @@ class MultipleSuiteLibraryImport(BaseTestCase): def test_libraries_stay_imported(self): self.set_baseurl_env() run = self.run_scenario("test_s2l_imported_multiple_a.robot test_s2l_imported_multiple_b.robot") - self.assert_run(run, expected_returncode=0) \ No newline at end of file + self.assert_run(run, expected_returncode=0) diff --git a/tests/test_unit.py b/tests/test_unit.py index 4c667ea..51e6983 100755 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -6,6 +6,7 @@ from robot.libraries.BuiltIn import BuiltIn from unittest import skipUnless import selenium +from selenium import webdriver from basetestcase import BaseTestCase from robotpageobjects import exceptions @@ -575,4 +576,20 @@ def test_package_on_path_with_fallback_succeeds(self): 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.") \ No newline at end of file + self.assertEqual(klass.__name__, "MyDBResultsPage", "MyDBResultsPage class should be selected.") + + +class ServiceArgsTestCase(BaseTestCase): + + def test_set_service_args(self): + class P(Page):pass + + os.environ["PO_SERVICE_ARGS"] = "--cookies-file=foo.txt" + service_args = P().service_args + self.assertTrue(isinstance(service_args, list), "Service args is a list") + self.assertEquals(len(service_args), 1, "Service args property has 1 member") + self.assertEquals( + service_args[0], + "--cookies-file=foo.txt", + "Service args is what we set it to be" + )