test_paver_bok_choy_cmds.py 2.47 KB
Newer Older
1 2 3 4 5 6 7 8

import os
import unittest
from pavelib.utils.test.suites.bokchoy_suite import BokChoyTestSuite

REPO_DIR = os.getcwd()


9
class TestPaverBokChoyCmd(unittest.TestCase):
10 11 12 13

    def setUp(self):
        self.request = BokChoyTestSuite('')

14
    def _expected_command(self, expected_text_append, expected_default_store=None):
15 16
        if expected_text_append:
            expected_text_append = "/" + expected_text_append
17 18 19 20 21 22 23 24 25
        expected_statement = ("DEFAULT_STORE={default_store} SCREENSHOT_DIR='{repo_dir}/test_root/log' "
                                       "BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' "
                                       "SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' "
                                       "nosetests {repo_dir}/common/test/acceptance/tests{exp_text} "
                                       "--with-xunit "
                                       "--xunit-file={repo_dir}/reports/bok_choy/xunit.xml "
                                       "--verbosity=2 ".format(default_store=expected_default_store,
                                                               repo_dir=REPO_DIR,
                                                               exp_text=expected_text_append))
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
        return expected_statement

    def test_default_bokchoy(self):
        self.assertEqual(self.request.cmd, self._expected_command(''))

    def test_suite_request_bokchoy(self):
        self.request.test_spec = "test_foo.py"
        self.assertEqual(self.request.cmd, self._expected_command(self.request.test_spec))

    def test_class_request_bokchoy(self):
        self.request.test_spec = "test_foo.py:FooTest"
        self.assertEqual(self.request.cmd, self._expected_command(self.request.test_spec))

    def test_case_request_bokchoy(self):
        self.request.test_spec = "test_foo.py:FooTest.test_bar"
        self.assertEqual(self.request.cmd, self._expected_command(self.request.test_spec))

Ben Patterson committed
43
    def test_default_bokchoy_with_draft_default_store(self):
44 45 46
        self.request.test_spec = "test_foo.py"
        self.request.default_store = "draft"
        self.assertEqual(self.request.cmd, self._expected_command(self.request.test_spec, "draft"))
47

48 49 50 51 52
    def test_default_bokchoy_with_invalid_default_store(self):
        # the cmd will dumbly compose whatever we pass in for the default_store
        self.request.test_spec = "test_foo.py"
        self.request.default_store = "invalid"
        self.assertEqual(self.request.cmd, self._expected_command(self.request.test_spec, "invalid"))