Ejemplo n.º 1
0
 def test_finding_subdirectory_controller(self):
     directory_controller = TestDataDirectoryController(_data_directory('Root'))
     subdirectory_controller = TestDataDirectoryController(_data_directory('Sub.suite'))
     directory_controller.add_child(subdirectory_controller)
     self.project._controller = directory_controller
     result = self.project.find_controller_by_longname('Root.Sub.suite')
     assert_equals(result, subdirectory_controller)
Ejemplo n.º 2
0
 def test_finding_subdirectory_controller(self):
     directory_controller = TestDataDirectoryController(_data_directory('Root'))
     subdirectory_controller = TestDataDirectoryController(_data_directory('Sub.suite'))
     directory_controller.add_child(subdirectory_controller)
     self.project._controller = directory_controller
     result = self.project.find_controller_by_longname('Root.Sub.suite')
     assert_equal(result, subdirectory_controller)
Ejemplo n.º 3
0
 def test_exclude(self):
     parent = lambda: 0
     project = self._mock_project()
     ctrl = TestDataDirectoryController(self.data, project, parent)
     parent.children = [ctrl]
     ctrl.exclude()
     self.assertEqual(len(parent.children), 1)
     self.assertTrue(parent.children[0].is_excluded())
     self.assertTrue(self.called)
Ejemplo n.º 4
0
 def test_exclude(self):
     parent = lambda:0
     project = self._mock_project()
     ctrl = TestDataDirectoryController(self.data, project, parent)
     parent.children = [ctrl]
     ctrl.exclude()
     self.assertEqual(len(parent.children), 1)
     self.assertTrue(parent.children[0].is_excluded())
     self.assertTrue(self.called)
Ejemplo n.º 5
0
 def _create_suite_structure_with_two_tests_with_same_name(self):
     directory_controller = TestDataDirectoryController(_data_directory('Ro.ot'))
     suite1_controller = TestCaseFileController(_testcasefile('Suite.1.txt'))
     test1 = suite1_controller.create_test('Te.st')
     suite2_controller = TestCaseFileController(_testcasefile('Suite.2.txt'))
     test2 = suite2_controller.create_test('Te.st')
     directory_controller.add_child(suite1_controller)
     directory_controller.add_child(suite2_controller)
     self.project._controller = directory_controller
     return test1, test2
Ejemplo n.º 6
0
 def _create_suite_structure_with_two_tests_with_same_name(self):
     directory_controller = TestDataDirectoryController(_data_directory('Ro.ot'))
     suite1_controller = TestCaseFileController(_testcasefile('Suite.1.txt'))
     test1 = suite1_controller.create_test('Te.st')
     suite2_controller = TestCaseFileController(_testcasefile('Suite.2.txt'))
     test2 = suite2_controller.create_test('Te.st')
     directory_controller.add_child(suite1_controller)
     directory_controller.add_child(suite2_controller)
     self.project._controller = directory_controller
     return test1, test2
 def test_reload_with_directory_suite(self):
     model_parent = object()
     controller_parent = object()
     ctrl = TestDataDirectoryController(TestDataDirectory(source=self._dirpath, parent=model_parent).populate(),
         parent=controller_parent)
     open(self._init_path, 'a').write('...  ninjaed more documentation')
     ctrl.reload()
     assert_equals(ctrl.settings[0].value,
                   'Ride unit testing file\\nninjaed more documentation')
     assert_equals(ctrl.parent, controller_parent)
     assert_equals(ctrl.data.parent, model_parent)
Ejemplo n.º 8
0
def testcase_controller(project=None, data=None):
    if data is None:
        data = BASE_DATA[:]
    base_directory_controller = TestDataDirectoryController(
        TestDataDirectory(), project)
    directory_controller = TestDataDirectoryController(
        TestDataDirectory(), project, base_directory_controller)
    tcf_controller = TestCaseFileController(create(data), project,
                                            directory_controller)
    tctablectrl = tcf_controller.tests
    return tctablectrl[0]
 def test_reload_with_directory_suite(self):
     model_parent = object()
     controller_parent = object()
     ctrl = TestDataDirectoryController(TestDataDirectory(source=self._dirpath, parent=model_parent).populate(),
         parent=controller_parent)
     open(self._init_path, 'a').write('...  ninjaed more documentation')
     ctrl.reload()
     assert_equals(ctrl.settings[0].value,
                   'Ride unit testing file\\nninjaed more documentation')
     assert_equals(ctrl.parent, controller_parent)
     assert_equals(ctrl.data.parent, model_parent)
Ejemplo n.º 10
0
 def test_finding_correct_testcase_when_two_files_with_same_name_start(self):
     directory_controller = TestDataDirectoryController(_data_directory('t'))
     suite1_controller = TestCaseFileController(_testcasefile('test.txt'))
     test1 = suite1_controller.create_test('A')
     suite2_controller = TestCaseFileController(_testcasefile('test2.txt'))
     test2 = suite2_controller.create_test('A')
     directory_controller.add_child(suite1_controller)
     directory_controller.add_child(suite2_controller)
     self.project._controller = directory_controller
     result1 = self.project.find_controller_by_longname('T.'+test1.longname, test1.display_name)
     assert_equals(result1, test1)
     result2 = self.project.find_controller_by_longname('T.'+test2.longname, test2.display_name)
     assert_equals(result2, test2)
Ejemplo n.º 11
0
 def test_finding_correct_testcase_when_two_files_with_same_name_start(self):
     directory_controller = TestDataDirectoryController(_data_directory('t'))
     suite1_controller = TestCaseFileController(_testcasefile('test.txt'))
     test1 = suite1_controller.create_test('A')
     suite2_controller = TestCaseFileController(_testcasefile('test2.txt'))
     test2 = suite2_controller.create_test('A')
     directory_controller.add_child(suite1_controller)
     directory_controller.add_child(suite2_controller)
     self.project._controller = directory_controller
     result1 = self.project.find_controller_by_longname('T.' + test1.longname, test1.display_name)
     assert_equal(result1, test1)
     result2 = self.project.find_controller_by_longname('T.' + test2.longname, test2.display_name)
     assert_equal(result2, test2)
Ejemplo n.º 12
0
 def test_deleting_file_suite_under_dir_suite(self):
     project = create_project()
     project._controller = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate(), project)
     original_children_length = len(project.data.children)
     file_suite = project.data.children[0]
     file_suite.remove()
     assert_true(len(project.data.children) == original_children_length-1, 'Child suite was not removed')
Ejemplo n.º 13
0
 def test_resource_directory_gets_nearest_possible_parent(self):
     self._set_data_directory_controller('tmp')
     self.project.data.add_child(TestDataDirectoryController(_data_directory(j('tmp', 'some'))))
     self._set_resources(j('tmp', 'some', 'resoruces', 'res.txt'))
     assert_equal(len(self.project.data.children), 1)
     assert_equal(len(self.project.data.children[0].children), 1)
     assert_equal(self.project.data.children[0].children[0].children, [self.project.resources[0]])
 def test_deleting_init_file(self):
     project = create_project()
     project._controller = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate(), project)
     os.remove(self._init_path)
     project.data.remove()
     open(self._init_path, 'w').write('*Settings*\nDocumentation  Ride unit testing file\n')
     assert_true(project.data.has_format() is False, project.data.data.initfile)
Ejemplo n.º 15
0
class DatafileIteratorTest(unittest.TestCase):
    def setUp(self):
        test_data_suite = TestDataDirectory(source=SUITEPATH).populate()
        self.directory_controller = TestDataDirectoryController(
            test_data_suite)

    def test_iterate_all(self):
        class Checker(object):
            def __init__(self):
                self.iteration_count = 0
                self.in_sub_dir = False

            def __call__(self, controller):
                self.iteration_count += 1
                print controller.filename
                if controller.filename and controller.filename.endswith(
                        'test.txt'):
                    self.in_sub_dir = True

        check_count_and_sub_dir = Checker()
        [
            check_count_and_sub_dir(df)
            for df in self.directory_controller.iter_datafiles()
        ]
        assert_true(check_count_and_sub_dir.iteration_count == 5)
        assert_true(check_count_and_sub_dir.in_sub_dir)
Ejemplo n.º 16
0
 def test_has_format(self):
     ctrl = TestDataDirectoryController(self.data)
     assert_false(ctrl.has_format())
     ctrl.mark_dirty()
     assert_false(ctrl.has_format())
     ctrl.data.initfile = os.path.join('source', '__init__.html')
     assert_true(ctrl.has_format())
Ejemplo n.º 17
0
 def test_has_format(self):
     ctrl = TestDataDirectoryController(self.data)
     assert_false(ctrl.has_format())
     ctrl.mark_dirty()
     assert_false(ctrl.has_format())
     ctrl.data.initfile = os.path.join('source', '__init__.html')
     assert_true(ctrl.has_format())
Ejemplo n.º 18
0
 def test_set_format(self):
     ctrl = TestDataDirectoryController(self.data)
     assert_false(ctrl.has_format())
     ctrl.set_format('txt')
     assert_true(ctrl.has_format())
     assert_equals(ctrl.source,
                   os.path.abspath(os.path.join('source', '__init__.txt')))
Ejemplo n.º 19
0
 def _create_model(self):
     suite = self._create_directory_suite('/top_suite')
     suite.children = [self._create_file_suite('sub_suite_%d.txt' % i)
                       for i in range(3)]
     res = ResourceFile()
     res.source = 'resource.txt'
     res.keyword_table.keywords.append(UserKeyword(res, 'Resource Keyword'))
     library_manager = LibraryManager(':memory:')
     library_manager.create_database()
     model = ChiefController(Namespace(FakeSettings()), library_manager=library_manager)
     model._controller = TestDataDirectoryController(suite)
     rfc = ResourceFileController(res, chief_controller=model)
     model.resources.append(rfc)
     model.insert_into_suite_structure(rfc)
     return model
Ejemplo n.º 20
0
class DatafileIteratorTest(unittest.TestCase):

    def setUp(self):
        test_data_suite = TestDataDirectory(source=SUITEPATH).populate()
        self.directory_controller = TestDataDirectoryController(test_data_suite)

    def test_iterate_all(self):
        class Checker(object):
            def __init__(self):
                self.iteration_count = 0
                self.in_sub_dir = False
            def __call__(self, controller):
                self.iteration_count += 1
                print controller.filename
                if controller.filename and controller.filename.endswith('test.txt'):
                    self.in_sub_dir = True
        check_count_and_sub_dir = Checker()
        [check_count_and_sub_dir(df) for df
                in self.directory_controller.iter_datafiles()]
        assert_true(check_count_and_sub_dir.iteration_count == 5)
        assert_true(check_count_and_sub_dir.in_sub_dir)
Ejemplo n.º 21
0
 def test_set_format(self):
     ctrl = TestDataDirectoryController(self.data)
     assert_false(ctrl.has_format())
     ctrl.set_format('txt')
     assert_true(ctrl.has_format())
     assert_equals(ctrl.source, os.path.abspath(os.path.join('source', '__init__.txt')))
Ejemplo n.º 22
0
 def test_reload_with_directory_suite(self):
     ctrl = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate())
     open(self._init_path, 'a').write('...  ninjaed more documentation')
     ctrl.reload()
     assert_equals(ctrl.settings[0].value,
                   'Ride unit testing file ninjaed more documentation')
Ejemplo n.º 23
0
 def test_mtime_with_directory_suite(self):
     ctrl = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate())
     assert_false(ctrl.has_been_modified_on_disk())
     os.utime(self._init_path, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())
Ejemplo n.º 24
0
 def test_longname(self):
     ctrl = TestDataDirectoryController(self.data)
     assert_equals(ctrl.longname, 'Source')
     ctrl.parent = lambda: 0
     ctrl.parent.longname = 'Parent'
     assert_equals(ctrl.longname, 'Parent.Source')
Ejemplo n.º 25
0
 def test_adding_test_data_directory_using_command(self):
     ctrl = TestDataDirectoryController(self.data)
     suite = ctrl.execute(AddTestDataDirectory(self.INIT_FILE_PATH))
     assert_equals(suite.data.parent, ctrl.data)
Ejemplo n.º 26
0
 def setUp(self):
     test_data_suite = TestDataDirectory(source=SUITEPATH).populate()
     self.directory_controller = TestDataDirectoryController(
         test_data_suite)
Ejemplo n.º 27
0
 def test_default_dir_is_source(self):
     self.data.initfile = os.path.join('source', '__init__.html')
     ctrl = TestDataDirectoryController(self.data)
     assert_true(ctrl.default_dir, os.path.dirname(ctrl.filename))
 def _set_data_directory_controller(self, dir):
     self.project._controller = TestDataDirectoryController(
         _data_directory(dir))
Ejemplo n.º 29
0
 def test_adding_test_case_file(self):
     new_data = TestDataDirectoryController(self.data).\
                 new_test_case_file(self.TEST_CASE_FILE_PATH)
     assert_true(new_data.dirty)
     assert_true(isinstance(new_data, TestCaseFileController))
     assert_equals(new_data.filename, self.TEST_CASE_FILE_PATH)
Ejemplo n.º 30
0
 def test_longname(self):
     ctrl = TestDataDirectoryController(self.data)
     assert_equals(ctrl.longname, 'Source')
     ctrl.parent = lambda:0
     ctrl.parent.longname = 'Parent'
     assert_equals(ctrl.longname, 'Parent.Source')
Ejemplo n.º 31
0
 def test_adding_test_case_file_using_command(self):
     ctrl = TestDataDirectoryController(self.data)
     suite = ctrl.execute(AddTestCaseFile(self.TEST_CASE_FILE_PATH))
     assert_equals(suite.data.parent, ctrl.data)
 def test_mtime_with_directory_suite(self):
     ctrl = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate())
     assert_false(ctrl.has_been_modified_on_disk())
     os.utime(self._init_path, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())
Ejemplo n.º 33
0
 def test_adding_test_suite_directory(self):
     new_data = TestDataDirectoryController(self.data).\
                     new_test_data_directory(self.INIT_FILE_PATH)
     assert_true(isinstance(new_data, TestDataDirectoryController))
     assert_equals(new_data.name, self.DATA_DIRECTORY_NAME)
     assert_equals(new_data.filename, self.INIT_FILE_PATH)
Ejemplo n.º 34
0
 def test_creation(self):
     ctrl = TestDataDirectoryController(self.data)
     for st in ctrl.settings:
         assert_true(st is not None)
     assert_equals(len(ctrl.settings), 6)
Ejemplo n.º 35
0
 def setUp(self):
     test_data_suite = TestDataDirectory(source=SUITEPATH).populate()
     self.directory_controller = TestDataDirectoryController(test_data_suite)
Ejemplo n.º 36
0
 def test_adding_test_case_file_using_command(self):
     ctrl = TestDataDirectoryController(self.data)
     suite = ctrl.execute(AddTestCaseFile(self.TEST_CASE_FILE_PATH))
     assert_equals(suite.data.parent, ctrl.data)
 def test_finding_root_directory_controller(self):
     self.project._controller = TestDataDirectoryController(
         _data_directory('Root'))
     result = self.project.find_controller_by_longname('Root')
     assert_equal(result, self.project._controller)
Ejemplo n.º 38
0
 def test_adding_test_data_directory_using_command(self):
     ctrl = TestDataDirectoryController(self.data)
     suite = ctrl.execute(AddTestDataDirectory(self.INIT_FILE_PATH))
     assert_equals(suite.data.parent, ctrl.data)