Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tests/scenarios/test_location_should_be_for_absolute_path.py
Original file line number Diff line number Diff line change
@@ -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()
unittest.main()
16 changes: 10 additions & 6 deletions tests/scenarios/test_location_should_be_for_relative_path.py
Original file line number Diff line number Diff line change
@@ -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()
unittest.main()
14 changes: 0 additions & 14 deletions tests/scenarios/test_service_args_cookie_file.py

This file was deleted.

30 changes: 1 addition & 29 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
self.assert_run(run, expected_returncode=0)
19 changes: 18 additions & 1 deletion tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
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"
)