class TestCaseNameValidationTest(unittest.TestCase):
    def setUp(self):
        self.ctrl = TestCaseFileController(TestCaseFile()).tests

    def test_valid_name(self):
        self._validate_name(VALID_NAME, True)

    def test_empty_name(self):
        self._validate_name('', False)

    def test_name_with_only_whitespace(self):
        self._validate_name('      ', False)

    def test_duplicate_name(self):
        self.ctrl.new(VALID_NAME)
        self._validate_name(VALID_NAME, False)
        self._validate_name(VALID_NAME.upper(), False)
        self._validate_name(VALID_NAME.replace(' ', '_'), False)

    def test_duplicate_name_when_previous_name_known(self):
        ctrl = self.ctrl.new(VALID_NAME)
        self._validate_name(VALID_NAME, True, ctrl)
        self._validate_name(VALID_NAME.upper(), True, ctrl)
        self._validate_name(VALID_NAME.replace(' ', '_'), True, ctrl)

    def _validate_name(self, name, expected_valid, named_ctrl=None):
        valid = not bool(
            self.ctrl.validate_name(name, named_ctrl).error_message)
        assert_equals(valid, expected_valid)
 def test_overwrite(self):
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate(),
                                   create_project())
     os.utime(self._filepath, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())
     ctrl.execute(SaveFile())
     assert_false(ctrl.has_been_modified_on_disk())
Exemplo n.º 3
0
 def test_overwrite(self):
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate(),
                                   ChiefController(Namespace()))
     os.utime(self._filepath, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())
     ctrl.save()
     assert_false(ctrl.has_been_modified_on_disk())
Exemplo n.º 4
0
 def test_reload(self):
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate())
     assert_equals(len(ctrl.tests), 1)
     open(self._filepath, 'a').write('Second Test  Log  Hello World!\n')
     ctrl.reload()
     assert_equals(len(ctrl.tests), 2)
     assert_equals(ctrl.tests[-1].name, 'Second Test')
Exemplo n.º 5
0
class TestCaseNameValidationTest(unittest.TestCase):

    def setUp(self):
        self.ctrl = TestCaseFileController(TestCaseFile()).tests

    def test_valid_name(self):
        self._validate_name(VALID_NAME, True)

    def test_empty_name(self):
        self._validate_name('', False)

    def test_name_with_only_whitespace(self):
        self._validate_name('      ', False)

    def test_duplicate_name(self):
        self.ctrl.new(VALID_NAME)
        self._validate_name(VALID_NAME, False)
        self._validate_name(VALID_NAME.upper(), False)
        self._validate_name(VALID_NAME.replace(' ', '_'), False)

    def test_duplicate_name_when_previous_name_known(self):
        ctrl = self.ctrl.new(VALID_NAME)
        self._validate_name(VALID_NAME, True, ctrl)
        self._validate_name(VALID_NAME.upper(), True, ctrl)
        self._validate_name(VALID_NAME.replace(' ', '_'), True, ctrl)

    def _validate_name(self, name, expected_valid, named_ctrl=None):
        valid = not bool(self.ctrl.validate_name(name, named_ctrl).error_message)
        assert_equals(valid, expected_valid)
 def test_finding_testcase_controller(self):
     suite_controller = TestCaseFileController(_testcasefile('Suite.txt'))
     test = suite_controller.create_test('Test 1')
     self.project._controller = suite_controller
     result = self.project.find_controller_by_longname(
         'Suite.Test 1', 'Test 1')
     assert_equal(result, test)
Exemplo n.º 7
0
 def setUp(self):
     self.tcf = TestCaseFile()
     filectrl = TestCaseFileController(self.tcf)
     filectrl.resource_import_modified = Mock()
     resource_file_controller_mock = lambda:0
     resource_file_controller_mock.add_known_import = lambda *_:0
     resu_factory_mock = lambda:0
     resu_factory_mock.find_with_import = lambda *_: resource_file_controller_mock
     self.ctrl = ImportSettingsController(filectrl, self.tcf.setting_table, resu_factory_mock)
Exemplo n.º 8
0
 def setUp(self):
     self.tcf = TestCaseFile()
     filectrl = TestCaseFileController(self.tcf)
     filectrl.resource_import_modified = Mock()
     resource_file_controller_mock = lambda:0
     resource_file_controller_mock.add_known_import = lambda *_:0
     resu_factory_mock = lambda:0
     resu_factory_mock.find_with_import = lambda *_: resource_file_controller_mock
     self.ctrl = ImportSettingsController(filectrl, self.tcf.setting_table, resu_factory_mock)
Exemplo n.º 9
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
Exemplo n.º 10
0
 def setUp(self):
     class Data(object):
         source = directory = None
     self.ctrl = TestCaseFileController(Data())
     self._has_unsaved_changes = False
     self._saved = False
     self.messages = [(self._changes, RideDataChangedToDirty),
                      (self._cleared, RideDataDirtyCleared)]
     for listener, topic in self.messages:
         PUBLISHER.subscribe(listener, topic)
class TestCaseFileControllerTest(unittest.TestCase):
    SOURCE_HTML = os.path.abspath(
        os.path.join('tmp', '.path.with.dots', 'test.cases.html'))
    SOURCE_TXT = SOURCE_HTML.replace('.html', '.txt')

    def setUp(self):
        self.ctrl = TestCaseFileController(
            TestCaseFile(source=self.SOURCE_HTML))

    def test_creation(self):
        for st in self.ctrl.settings:
            assert_true(st is not None)
        assert_equal(len(self.ctrl.settings), 9)
        assert_false(self.ctrl.dirty)

    def test_has_format(self):
        assert_true(self.ctrl.has_format())

    @unittest.skip("ERRORS with RF 3.1")
    def test_get_format(self):
        assert_equal(self.ctrl.get_format(), 'html')

    @unittest.skip("ERRORS with RF 3.1")
    def test_source(self):
        assert_equal(self.ctrl.filename, self.SOURCE_HTML)

    def test_longname(self):
        assert_equal(self.ctrl.longname, 'Test.Cases')
        self.ctrl.parent = lambda: 0
        self.ctrl.parent.longname = 'Parent'
        assert_equal(self.ctrl.longname, 'Parent.Test.Cases')

    @unittest.skip("ERRORS with RF 3.1")
    def test_set_format(self):
        self.ctrl.set_format('txt')
        assert_equal(self.ctrl.filename, self.SOURCE_TXT)

    def test_add_test_or_kw(self):
        assert_equal(len(self.ctrl.tests), 0)
        new_test = TestCaseController(self.ctrl,
                                      TestCase(TestCaseFile(), 'New test'))
        self.ctrl.add_test_or_keyword(new_test)
        assert_equal(len(self.ctrl.tests), 1)
        assert_true(
            self.ctrl.tests[0]._test.parent.parent is self.ctrl.datafile)
        assert_true(self.ctrl.dirty)

    def test_new_test(self):
        test_ctrl = self.ctrl.create_test('Foo')
        assert_equal(test_ctrl.name, 'Foo')

    def test_create_keyword(self):
        kw_ctrl = self.ctrl.create_keyword('An UK')
        assert_equal(kw_ctrl.name, 'An UK')

    def test_create_keyword_with_args(self):
        kw_ctrl = self.ctrl.create_keyword('UK', '${a1} | ${a2}')
        assert_equal(kw_ctrl.name, 'UK')
        assert_equal(kw_ctrl.data.args.value, ['${a1}', '${a2}'])
 def test_reload(self):
     controller_parent = object()
     model_parent = object()
     ctrl = TestCaseFileController(
         TestCaseFile(parent=model_parent, source=self._filepath).populate(),
         parent=controller_parent)
     assert_equals(len(ctrl.tests), 1)
     open(self._filepath, 'a').write('Second Test  Log  Hello World!\n')
     ctrl.reload()
     assert_equals(len(ctrl.tests), 2)
     assert_equals(ctrl.tests[-1].name, 'Second Test')
     assert_equals(ctrl.parent, controller_parent)
     assert_equals(ctrl.data.parent, model_parent)
 def test_reload(self):
     controller_parent = object()
     model_parent = object()
     ctrl = TestCaseFileController(
         TestCaseFile(parent=model_parent, source=self._filepath).populate(),
         parent=controller_parent)
     assert_equals(len(ctrl.tests), 1)
     open(self._filepath, 'a').write('Second Test  Log  Hello World!\n')
     ctrl.reload()
     assert_equals(len(ctrl.tests), 2)
     assert_equals(ctrl.tests[-1].name, 'Second Test')
     assert_equals(ctrl.parent, controller_parent)
     assert_equals(ctrl.data.parent, model_parent)
Exemplo n.º 14
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)
Exemplo n.º 15
0
 def _create_test(self, name='test'):
     suite = TestCaseFile(source='suite')
     suite_controller = TestCaseFileController(suite)
     parent = TestCaseTableController(suite_controller,
                                      suite.testcase_table)
     test = TestCase(parent=lambda: 0, name=name)
     return TestCaseController(parent, test)
Exemplo n.º 16
0
def TestCaseControllerWithSteps(project=None, source='some_suite.txt'):
    tcf = TestCaseFile()
    tcf.source = source
    tcf.setting_table.suite_setup.name = 'Suite Setup Kw'
    tcf.setting_table.test_setup.name = SUITE_TEST_SETUP_KEYWORD
    tcf.setting_table.test_teardown.name = 'Test Teardown Kw'
    tcf.setting_table.suite_teardown.name = 'Suite Teardown Kw'
    tcf.setting_table.test_template.value = SUITE_TEST_TEMPLATE_KEYWORD
    testcase = _create_testcase(tcf)
    uk = tcf.keyword_table.add(USERKEYWORD1_NAME)
    uk.add_step([KEYWORD_IN_USERKEYWORD1])
    uk = tcf.keyword_table.add(USERKEYWORD2_NAME)
    uk.add_step(['No Operation'])
    uk = tcf.keyword_table.add(EMBEDDED_ARGUMENTS_KEYWORD)
    uk.add_step(['No Operation'])
    if project is None:
        library_manager = LibraryManager(':memory:')
        library_manager.create_database()
        project = Project(Namespace(FakeSettings()),
                          library_manager=library_manager)
    tcf_ctrl = TestCaseFileController(tcf, project)
    project._controller = tcf_ctrl
    tctablectrl = TestCaseTableController(tcf_ctrl,
                                          tcf.testcase_table)
    return TestCaseController(tctablectrl, testcase), project._namespace
class TestCaseCreationTest(unittest.TestCase):
    def setUp(self):
        self.ctrl = TestCaseFileController(TestCaseFile()).tests

    def test_whitespace_is_stripped(self):
        test = self.ctrl.new('   ' + VALID_NAME + '\t   \n')
        assert_equals(test.name, VALID_NAME)
Exemplo n.º 18
0
class TestCaseFileControllerTest(unittest.TestCase):
    SOURCE_HTML = os.path.abspath(os.path.join("tmp", ".path.with.dots", "test.cases.html"))
    SOURCE_TXT = SOURCE_HTML.replace(".html", ".txt")

    def setUp(self):
        self.ctrl = TestCaseFileController(TestCaseFile(source=self.SOURCE_HTML))

    def test_creation(self):
        for st in self.ctrl.settings:
            assert_true(st is not None)
        assert_equals(len(self.ctrl.settings), 9)
        assert_false(self.ctrl.dirty)

    def test_has_format(self):
        assert_true(self.ctrl.has_format())

    def test_get_format(self):
        assert_equals(self.ctrl.get_format(), "html")

    def test_source(self):
        assert_equals(self.ctrl.filename, self.SOURCE_HTML)

    def test_longname(self):
        assert_equals(self.ctrl.longname, "Test.Cases")
        self.ctrl.parent = lambda: 0
        self.ctrl.parent.longname = "Parent"
        assert_equals(self.ctrl.longname, "Parent.Test.Cases")

    def test_set_format(self):
        self.ctrl.set_format("txt")
        assert_equals(self.ctrl.filename, self.SOURCE_TXT)

    def test_add_test_or_kw(self):
        assert_equals(len(self.ctrl.tests), 0)
        new_test = TestCaseController(self.ctrl, TestCase(TestCaseFile(), "New test"))
        self.ctrl.add_test_or_keyword(new_test)
        assert_equals(len(self.ctrl.tests), 1)
        assert_true(self.ctrl.tests[0]._test.parent.parent is self.ctrl.datafile)
        assert_true(self.ctrl.dirty)

    def test_new_test(self):
        test_ctrl = self.ctrl.create_test("Foo")
        assert_equals(test_ctrl.name, "Foo")

    def test_create_keyword(self):
        kw_ctrl = self.ctrl.create_keyword("An UK")
        assert_equals(kw_ctrl.name, "An UK")

    def test_create_keyword_with_args(self):
        kw_ctrl = self.ctrl.create_keyword("UK", "${a1} | ${a2}")
        assert_equals(kw_ctrl.name, "UK")
        assert_equals(kw_ctrl.data.args.value, ["${a1}", "${a2}"])
Exemplo n.º 19
0
class TestCaseFileControllerTest(unittest.TestCase):
    SOURCE_HTML = os.path.abspath(os.path.join('tmp', '.path.with.dots', 'test.cases.html'))
    SOURCE_TXT = SOURCE_HTML.replace('.html', '.txt')

    def setUp(self):
        self.ctrl = TestCaseFileController(TestCaseFile(source=self.SOURCE_HTML))

    def test_creation(self):
        for st in self.ctrl.settings:
            assert_true(st is not None)
        assert_equals(len(self.ctrl.settings), 9)
        assert_false(self.ctrl.dirty)

    def test_has_format(self):
        assert_true(self.ctrl.has_format())

    def test_get_format(self):
        assert_equals(self.ctrl.get_format(), 'html')

    def test_source(self):
        assert_equals(self.ctrl.filename, self.SOURCE_HTML)

    def test_longname(self):
        assert_equals(self.ctrl.longname, 'Test.Cases')
        self.ctrl.parent = lambda:0
        self.ctrl.parent.longname = 'Parent'
        assert_equals(self.ctrl.longname, 'Parent.Test.Cases')

    def test_set_format(self):
        self.ctrl.set_format('txt')
        assert_equals(self.ctrl.filename, self.SOURCE_TXT)

    def test_add_test_or_kw(self):
        assert_equals(len(self.ctrl.tests), 0)
        new_test = TestCaseController(self.ctrl, TestCase(TestCaseFile(), 'New test'))
        self.ctrl.add_test_or_keyword(new_test)
        assert_equals(len(self.ctrl.tests), 1)
        assert_true(self.ctrl.tests[0]._test.parent.parent is self.ctrl.datafile)
        assert_true(self.ctrl.dirty)

    def test_new_test(self):
        test_ctrl = self.ctrl.create_test('Foo')
        assert_equals(test_ctrl.name, 'Foo')

    def test_create_keyword(self):
        kw_ctrl = self.ctrl.create_keyword('An UK')
        assert_equals(kw_ctrl.name, 'An UK')

    def test_create_keyword_with_args(self):
        kw_ctrl = self.ctrl.create_keyword('UK', '${a1} | ${a2}')
        assert_equals(kw_ctrl.name, 'UK')
        assert_equals(kw_ctrl.data.args.value, ['${a1}', '${a2}'])
Exemplo n.º 20
0
 def test_deleting_source_should_remove_it_from_model(self):
     project = create_project()
     project._controller = TestCaseFileController(TestCaseFile(source=self._filepath), project)
     os.remove(self._filepath)
     ctrl = project.data
     ctrl.remove()
     assert_true(project.data is None)
     assert_true(self._removed_datafile is ctrl)
Exemplo n.º 21
0
class TestCaseCreationTest(unittest.TestCase):

    def setUp(self):
        self.ctrl = TestCaseFileController(TestCaseFile()).tests

    def test_whitespace_is_stripped(self):
        test = self.ctrl.new('   ' + VALID_NAME + '\t   \n')
        assert_equals(test.name, VALID_NAME)
Exemplo n.º 22
0
 def setUp(self):
     self.tcf = TestCaseFile()
     uk = self.tcf.keyword_table.add('UK')
     uk.add_step(['No Operation'])
     uk2 = self.tcf.keyword_table.add('UK 2')
     tablectrl = KeywordTableController(TestCaseFileController(self.tcf),
                                        self.tcf.keyword_table)
     self.ctrl = UserKeywordController(tablectrl, uk)
     self.ctrl2 = UserKeywordController(tablectrl, uk2)
Exemplo n.º 23
0
 def test_deleting_source_should_remove_it_from_model(self):
     chief = create_chief()
     chief._controller = TestCaseFileController(
         TestCaseFile(source=self._filepath), chief)
     os.remove(self._filepath)
     ctrl = chief.data
     ctrl.remove()
     assert_true(chief.data is None)
     assert_true(self._removed_datafile is ctrl)
Exemplo n.º 24
0
 def setUp(self):
     self.tcf = TestCaseFile()
     self.testcase = self.tcf.testcase_table.add('Test')
     self.testcase.add_step(['Log', 'Hello'])
     self.testcase.add_step(['No Operation'])
     self.testcase.add_step(['Foo'])
     self.tcf.testcase_table.add('Another Test')
     tctablectrl = TestCaseTableController(TestCaseFileController(self.tcf),
                                           self.tcf.testcase_table)
     self.ctrl = TestCaseController(tctablectrl, self.testcase)
Exemplo n.º 25
0
 def setUp(self):
     class Data(object):
         source = directory = None
     self.ctrl = TestCaseFileController(Data())
     self._has_unsaved_changes = False
     self._saved = False
     self.messages = [(self._changes, RideDataChangedToDirty),
                      (self._cleared, RideDataDirtyCleared)]
     for listener, topic in self.messages:
         PUBLISHER.subscribe(listener, topic)
Exemplo n.º 26
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]
Exemplo n.º 27
0
 def _create_controller(self, path='some.txt'):
     self._filenames_to_remove.append(path)
     self.ctrl = TestCaseFileController(TestCaseFile(source=path))
     self.saved = False
     self.deleted = False
     self._message = None
     self._error_message = None
     def save(*args): self.saved = True
     def remove_from_filesystem(*Args): self.deleted = True
     self.ctrl.save = save
     self.ctrl.remove_from_filesystem = remove_from_filesystem
     return self.ctrl
Exemplo n.º 28
0
 def test_overwrite(self):
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate(),
                                   create_project())
     os.utime(self._filepath, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())
     ctrl.execute(SaveFile())
     assert_false(ctrl.has_been_modified_on_disk())
Exemplo n.º 29
0
 def setUp(self):
     self.tcf = TestCaseFile()
     self.tcf.setting_table.add_library('somelib', ['foo', 'bar'])
     self.tcf.setting_table.add_resource('resu')
     self.tcf.setting_table.add_library('BuiltIn', ['WITH NAME', 'InBuilt'])
     self.tcf_ctrl = TestCaseFileController(self.tcf, ImportControllerTest.FakeParent())
     self.tcf_ctrl.data.directory = 'tmp'
     self.parent = ImportSettingsController(self.tcf_ctrl, self.tcf.setting_table,
         resource_file_controller_factory=self._resource_file_controller_factory_mock())
     self.add_import_listener = PublisherListener(RideImportSettingAdded)
     self.changed_import_listener = PublisherListener(RideImportSettingChanged)
     self.removed_import_listener = PublisherListener(RideImportSettingRemoved)
     self.import_listener = PublisherListener(RideImportSetting)
Exemplo n.º 30
0
 def _create_data(self, resource_name, resource_import):
     res_path = os.path.abspath(resource_name)
     tcf = TestCaseFile(source=os.path.abspath('test.txt'))
     tcf.setting_table.add_resource(resource_import)
     tcf.variable_table.add('${dirname}', os.path.abspath('.').replace('\\', '\\\\'))
     tcf.variable_table.add('${path}', os.path.abspath(resource_name).replace('\\', '\\\\'))
     library_manager = LibraryManager(':memory:')
     library_manager.create_database()
     self.project = Project(Namespace(FakeSettings()), FakeSettings(), library_manager)
     self.project._controller = TestCaseFileController(tcf, self.project)
     res = ResourceFile(source=res_path)
     self.res_controller = \
         self.project._resource_file_controller_factory.create(res)
     self.project._namespace._resource_factory.cache[os.path.normcase(res_path)] = res
Exemplo n.º 31
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
Exemplo n.º 32
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)
Exemplo n.º 33
0
class TestCaseAndUserKeywordCopyingTest(unittest.TestCase):
    controller = TestCaseFileController(
        TestCaseFile(source=COMPLEX_SUITE_PATH).populate())

    def test_test_case_copy(self):
        test = self.controller.tests[0]
        copy = test.copy('New Name')
        assert_equal(copy.name, 'New Name')
        for orig, copied in zip(test.settings, copy.settings):
            assert_equal(orig.value, copied.value)
            assert_true(copied is not orig)
        assert_equal(test.steps, copy.steps)
        assert_true(test.steps is not copy.steps)

    def test_keyword_copy(self):
        test = self.controller.keywords[0]
        copy = test.copy('New Name')
        assert_equal(copy.name, 'New Name')
        for orig, copied in zip(test.settings, copy.settings):
            assert_equal(orig.value, copied.value)
            assert_true(copied is not orig)
        assert_equal(test.steps, copy.steps)
        assert_true(test.steps is not copy.steps)

    def test_test_copy_performance(self):
        self._run_copy_test(self.controller.tests[0])

    def test_keyword_copy_performance(self):
        self._run_copy_test(self.controller.keywords[0])

    def _run_copy_test(self, item):
        self._test_copy(item, 10)
        self._test_copy(item, 200)

    def _test_copy(self, item, count):
        start_time = time.time()
        for i in range(0, count):
            item.copy(str(i))
        self.assertTrue(time.time() < (start_time + 2),
                        "Copy operation takes too long time")
Exemplo n.º 34
0
 def test_size_change(self):
     os.utime(self._filepath, None)
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate())
     with open(self._filepath, 'a') as file:
         file.write('#Ninja edit\n')
     assert_true(ctrl.has_been_modified_on_disk())
Exemplo n.º 35
0
class TestMarkUnMarkDirty(unittest.TestCase):

    def setUp(self):
        class Data(object):
            source = directory = None
        self.ctrl = TestCaseFileController(Data())
        self._has_unsaved_changes = False
        self._saved = False
        self.messages = [(self._changes, RideDataChangedToDirty),
                         (self._cleared, RideDataDirtyCleared)]
        for listener, topic in self.messages:
            PUBLISHER.subscribe(listener, topic)

    def tearDown(self):
        for listener, topic in self.messages:
            PUBLISHER.unsubscribe(listener, topic)
        if os.path.exists('path'):
            shutil.rmtree('path')

    def _changes(self, payload):
        self._has_unsaved_changes = payload.datafile

    def _cleared(self, payload):
        self._saved = payload.datafile

    def test_marking_data_dirty_publishes_data_has_changes_message(self):
        self.ctrl.mark_dirty()
        assert_equals(self._has_unsaved_changes, self.ctrl)

    def test_clearing_dirty_mark_publishes_data_saved_message(self):
        self.ctrl.mark_dirty()
        self.ctrl.unmark_dirty()
        assert_equals(self._saved, self.ctrl)

    def test_remarking_data_dirty_does_not_publish_data_has_changes_message(self):
        self.ctrl.mark_dirty()
        self._has_unsaved_changes = None
        self.ctrl.mark_dirty()
        assert_equals(self._has_unsaved_changes, None)

    def test_reclearing_dirty_mark_does_not_publish_data_saved_message(self):
        self.ctrl.unmark_dirty()
        self._saved = None
        self.ctrl.unmark_dirty()
        assert_equals(self._saved, None)
Exemplo n.º 36
0
 def test_finding_testcase_controller(self):
     suite_controller = TestCaseFileController(_testcasefile('Suite.txt'))
     test = suite_controller.create_test('Test 1')
     self.project._controller = suite_controller
     result = self.project.find_controller_by_longname('Suite.Test 1', 'Test 1')
     assert_equals(result, test)
 def setUp(self):
     self.ctrl = TestCaseFileController(TestCaseFile()).tests
Exemplo n.º 38
0
 def setUp(self):
     self.tcf = TestCaseFile()
     self._add_var('${foo}', 'foo')
     self._add_var('@{bar}', ['b', 'a', 'r'])
     self.ctrl = VariableTableController(TestCaseFileController(self.tcf),
                                         self.tcf.variable_table)
Exemplo n.º 39
0
class TestMarkUnMarkDirty(unittest.TestCase):
    def setUp(self):
        class Data(object):
            source = directory = None

        self.ctrl = TestCaseFileController(Data())
        self._has_unsaved_changes = False
        self._saved = False
        self.messages = [(self._changes, RideDataChangedToDirty),
                         (self._cleared, RideDataDirtyCleared)]
        for listener, topic in self.messages:
            PUBLISHER.subscribe(listener, topic)

    def tearDown(self):
        for listener, topic in self.messages:
            PUBLISHER.unsubscribe(listener, topic)
        if os.path.exists('path'):
            shutil.rmtree('path')

    def _changes(self, payload):
        self._has_unsaved_changes = payload.datafile

    def _cleared(self, payload):
        self._saved = payload.datafile

    def test_marking_data_dirty_publishes_data_has_changes_message(self):
        self.ctrl.mark_dirty()
        assert_equals(self._has_unsaved_changes, self.ctrl)

    def test_clearing_dirty_mark_publishes_data_saved_message(self):
        self.ctrl.mark_dirty()
        self.ctrl.unmark_dirty()
        assert_equals(self._saved, self.ctrl)

    def test_remarking_data_dirty_does_not_publish_data_has_changes_message(
            self):
        self.ctrl.mark_dirty()
        self._has_unsaved_changes = None
        self.ctrl.mark_dirty()
        assert_equals(self._has_unsaved_changes, None)

    def test_reclearing_dirty_mark_does_not_publish_data_saved_message(self):
        self.ctrl.unmark_dirty()
        self._saved = None
        self.ctrl.unmark_dirty()
        assert_equals(self._saved, None)
Exemplo n.º 40
0
 def setUp(self):
     self.ctrl = TestCaseFileController(
         TestCaseFile(source=self.SOURCE_HTML))
 def test_size_change(self):
     os.utime(self._filepath, None)
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate())
     open(self._filepath, 'a').write('#Ninja edit\n')
     assert_true(ctrl.has_been_modified_on_disk())
 def test_mtime(self):
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate())
     assert_false(ctrl.has_been_modified_on_disk())
     os.utime(self._filepath, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())
Exemplo n.º 43
0
 def setUp(self):
     self.tcf = TestCaseFile()
     filectrl = TestCaseFileController(self.tcf)
     filectrl.resource_import_modified = Mock()
     self.ctrl = ImportSettingsController(filectrl, self.tcf.setting_table)
Exemplo n.º 44
0
 def setUp(self):
     self.ctrl = TestCaseFileController(TestCaseFile()).tests
Exemplo n.º 45
0
def file_controller():
    return TestCaseFileController(TestCaseFile())
Exemplo n.º 46
0
 def setUp(self):
     self.ctrl = TestCaseFileController(TestCaseFile(source=self.SOURCE_HTML))
Exemplo n.º 47
0
 def setUp(self):
     self.tcf = TestCaseFile()
     self.tcf.setting_table.add_metadata('Meta name', 'Some value')
     self.ctrl = MetadataListController(TestCaseFileController(self.tcf),
                                        self.tcf.setting_table)
Exemplo n.º 48
0
 def setUp(self):
     _TestMacroCommands.setUp(self)
     self._ctrl = TestCaseFileController(TestCaseFile())
Exemplo n.º 49
0
 def test_mtime(self):
     ctrl = TestCaseFileController(TestCaseFile(source=self._filepath).populate())
     assert_false(ctrl.has_been_modified_on_disk())
     os.utime(self._filepath, (1,1))
     assert_true(ctrl.has_been_modified_on_disk())