def roTroNo(self): if getattr(self.args, 'fromfile'): conf = config.ConfigFile(self.args.switch) tests = audit.TestFile() tests.load(TEST_TEMPLATE) auditor = audit.AuditTests(config=conf, tests=tests, test_group=self.args.testGroup) auditor.run() for test in auditor.last_results: result = 'OK' if test.result else 'FAIL' print('%s: %s' % (test.name, result))
def test_run_test_group_not_found_raises_error(self): suite = audit.AuditTests(C.FakeConfigFile()) suite.tests = audit.TestFile('fake_file') suite.test_group = 'testGroup2' self.assertRaises(E.TestGroupDoesNotExistError, suite.run)
def test_run_calls_testcase_getresult(self): suite = audit.AuditTests(C.FakeConfigFile()) suite.tests = audit.TestFile('fake_file') suite.test_group = 'testGroup1' suite.run() audit.TestCase().get_result.assert_called_once_with(suite.config)
def test_run_unset_test_group_raises_error(self): suite = audit.AuditTests(C.FakeConfigFile()) suite.tests = audit.TestFile('fake_file') self.assertRaises(E.TestGroupNotSetError, suite.run)
def test_test_group_property_sets_test_group(self): my_testgroup = 'group_to_test' suite = audit.AuditTests(C.FakeConfigFile()) suite.test_group = my_testgroup self.assertIs(suite.test_group, my_testgroup)
def test_run_calls_testfile_find_test_by_name(self): suite = audit.AuditTests(C.FakeConfigFile()) suite.tests = audit.TestFile('fake_file') suite.test_group = 'testGroup1' suite.run() suite.tests.find_test_by_name.assert_called_once_with('test1')
def test_tests_property_sets_tests(self): my_tests = audit.TestFile() suite = audit.AuditTests(C.FakeConfigFile()) suite.tests = my_tests self.assertIs(suite.tests, my_tests)
def test_init_named_attribute_sets_test_group(self): my_testgroup = 'group_to_test' suite = audit.AuditTests(C.FakeConfigFile(), test_group=my_testgroup) self.assertIs(suite.test_group, my_testgroup)
def test_init_named_attribute_sets_tests(self): my_tests = audit.TestFile() suite = audit.AuditTests(C.FakeConfigFile(), tests=my_tests) self.assertIs(suite.tests, my_tests)
def test_init_sets_test_group(self): my_testgroup = 'group_to_test' suite = audit.AuditTests(C.FakeConfigFile(), audit.TestFile(), my_testgroup) self.assertIs(suite.test_group, my_testgroup)
def test_init_sets_configfile(self): my_config = C.FakeConfigFile() suite = audit.AuditTests(my_config) self.assertIs(suite.config, my_config)