7
from runner import Bootstrap
9
class BootstrapTest(unittest.TestCase):
12
self.__create_output_dir
13
self.gears_binaries = "testdata/windows/installers"
14
self.testrunner_mock = pmock.Mock()
15
self.suites_report_mock = pmock.Mock()
16
self.installers = [pmock.Mock(), pmock.Mock()]
17
self.bootstrap = Bootstrap(self.gears_binaries, self.installers,
18
self.testrunner_mock, self.suites_report_mock)
22
self.testrunner_mock.verify()
23
self.__delete_output_dir()
24
self.suites_report_mock.verify()
25
for installer in self.installers:
29
def testStartTesting(self):
30
self.testrunner_mock.expects(pmock.once()).runTests()
31
self.bootstrap.startTesting()
34
def testReportResultsWritesToFile(self):
35
test_result_data = {'browser1': 'TIMED-OUT'}
36
self.testrunner_mock.expects(pmock.once()).runTests() \
37
.will(pmock.return_value(test_result_data))
38
output_stream = StringIO.StringIO()
39
self.suites_report_mock.expects(pmock.once()).method("writeReport")
40
self.bootstrap.startTesting()
41
self.bootstrap.writeResultsToFile()
44
def testInstall(self):
45
for installer in self.installers:
46
installer.expects(pmock.once()).install()
47
self.bootstrap.install()
51
self.__create_output_dir()
52
self.assert_(os.path.exists('output'))
53
self.bootstrap.clean()
54
self.assert_(not os.path.exists('output'))
57
def testCleanDoesNotFailIfOutputDirMissing(self):
58
self.__delete_output_dir()
59
self.assert_(not os.path.exists('output'))
60
self.bootstrap.clean()
63
def __create_output_dir(self):
64
self.__delete_output_dir()
68
def __delete_output_dir(self):
69
if (os.path.exists('output')):
70
shutil.rmtree('output')
73
if __name__ == "__main__":