def test_unsubscribe_with_class(self): listener_count = len(PUBLISHER._listeners[self.plugin]) self.plugin.unsubscribe(self.plugin.OnTestEventClass, RideTestMessage) RideTestMessage().publish() assert_none(self.plugin.class_handler_topic) assert_equals( len(PUBLISHER._listeners[self.plugin]), listener_count - 1)
def test_end_suite_restores_previous_instance_with_one_suite(self): self.lib.start_test() self.lib.get_instance() self.lib.end_test() self.lib.get_instance() self.lib.end_suite() assert_none(self.lib._libinst)
def test_unsubscribe_with_class(self): listener_count = len(PUBLISHER._listeners[self.plugin]) self.plugin.unsubscribe(self.plugin.OnTestEventClass, RideTestMessage) RideTestMessage().publish() assert_none(self.plugin.class_handler_topic) assert_equals(len(PUBLISHER._listeners[self.plugin]), listener_count - 1)
def test_cache_expiration(self): cache = ExpiringCache(0.01) cache.put('a', 'b') time.sleep(0.1) assert_none(cache.get('a')) cache.put('a', 'c') assert_equals('c', cache.get('a'))
def test_get_set_del_non_ascii_vars(self): set_env_var(NON_ASCII_VAR, NON_ASCII_VAL) for k, v in os.environ.items(): assert_true(isinstance(k, str) and isinstance(v, str)) assert_equals(get_env_var(NON_ASCII_VAR), NON_ASCII_VAL) assert_equals(del_env_var(NON_ASCII_VAR), NON_ASCII_VAL) assert_none(get_env_var(NON_ASCII_VAR))
def test_non_global_dynamic_handlers(self): lib = TestLibrary("RunKeywordLibrary") assert_equal(len(lib.handlers), 2) assert_true('Run Keyword That Passes' in lib.handlers) assert_true('Run Keyword That Fails' in lib.handlers) assert_none(lib.handlers['Run Keyword That Passes']._method) assert_none(lib.handlers['Run Keyword That Fails']._method)
def _verify_import_reference_is_not_resolved(self): imported_controller = self.import_setting.get_imported_controller() if imported_controller: msg = 'Resolved to source %s' % imported_controller.source else: msg = None assert_none(imported_controller, msg)
def _get_lib_and_instance(self, name): lib = TestLibrary(name) if lib.scope.is_global: assert_not_none(lib._libinst) else: assert_none(lib._libinst) return lib, lib._libinst
def test_init(self): assert_none(self.tcf.source) assert_true( isinstance(self.tcf.setting_table, TestCaseFileSettingTable)) assert_true(isinstance(self.tcf.variable_table, VariableTable)) assert_true(isinstance(self.tcf.testcase_table, TestCaseTable)) assert_true(isinstance(self.tcf.keyword_table, KeywordTable))
def test_valid_arguments_validation(self): for arg in [ "${arg}", "${arg}|${arg2}", "${arg}=", "${arg}=default val", "${a} | ${b}=d | ${c}=\\| | ${d}=", "@{list}", "${a} | ${b} | ${c}=1 | ${d}=2 | ${e}=3 | @{f}" ]: assert_none(self.validate(arg))
def test_setup_is_removed_when_set_to_none(self): kw = Keyword() kws = Keywords(keywords=[Keyword(type='setup'), kw]) kws.setup = None assert_none(kws.setup) assert_equal(list(kws), [kw]) kws.setup = None assert_none(kws.setup) assert_equal(list(kws), [kw])
def test_teardown_is_removed_when_set_to_none(self): kw = Keyword() kws = Keywords(keywords=[kw, Keyword(type='teardown')]) kws.teardown = None assert_none(kws.teardown) assert_equal(list(kws), [kw]) kws.teardown = None assert_none(kws.teardown) assert_equal(list(kws), [kw])
def _run_tests(self, suite_inst, count=3): old_insts = [suite_inst] for _ in range(count): self.lib.start_test() assert_none(self.lib._libinst) inst = self.lib.get_instance() assert_false(inst in old_insts) old_insts.append(inst) self.lib.end_test() assert_true(self.lib._libinst is suite_inst)
def test_valid_arguments_validation(self): for arg in [ "${arg}", "${arg}|${arg2}", "${arg}=", "${arg}=def val", "${a} | ${b}=d | ${c}=\\| | ${d}=", "@{list}", "${a} | ${b} | ${c}=1 | ${d}=2 | ${e}=3 | @{f}", ]: assert_none(self.validate(arg))
def test_name(self): assert_none(self.tcf.name) for source, name in [('hello.txt', 'Hello'), ('hello', 'Hello'), ('hello_world.tsv', 'Hello World'), ('HELLO_world.htm', 'HELLO world'), ('1name', '1Name'), (' h i w o r l d .htm', 'H I W O R L D'), ('HelloWorld.txt', 'HelloWorld'), ('09__h_E_l_l_o_', 'h E l l o'), ('prefix__the__name', 'The Name')]: self.tcf.source = os.path.abspath(source) assert_equal(self.tcf.name, name)
def check_quick_inv_match_obj_from_quick_inv_task(quick_inv_task, agent, no_rca): match_agent = TbQuickInvMatchObjectInfo.find_by_slf_key_and_agent( quick_inv_task.SLF_Key, agent) assert_not_none(match_agent, "agent %s should exist" % agent) assert_equal(match_agent.RetroScanData_MD5, quick_inv_task.RetroScanData_MD5, "RetroScanData_MD5 should be the same") assert_equal(match_agent.RetroScanCategory, quick_inv_task.RetroScanCategory, "RetroScanCategory should be the same") if no_rca: assert_none( match_agent.RCAScanID, "RCAScanID should be NULL when RCA return no affected or yet to run RCA" )
def check_init_rca_result(criteria, criteria_type, agents): agents = agents.split(',') for index in range(0, len(agents)): rca_agent = TbRCATask.find_by_criteria_and_agent( criteria, agents[index]) assert_not_none(rca_agent, "RCA record for agent %s should exist" % agents[index]) assert_equal(rca_agent.CriteriaType, int(criteria_type), "RCA criteriaType should be %s" % criteria_type) assert_none(rca_agent.TaskID, "RCA TaskID should not be NULL") assert_none(rca_agent.ScanSummaryID, "RCA ScanSummaryID should not be NULL") assert_equal(rca_agent.Status, 0, "RCA status should be 0 for init value") assert_equal(rca_agent.IsAffected, 0, "RCA IsAffected should be 0 for init value") assert_equal(rca_agent.IsSync, 0, "RCA IsSync should be 0 for init value")
def test_given_when_then_and_aliases(self): assert_not_none( self.ns.find_user_keyword( self.tcf, ' Given UK Fromresource from rESOURCE with variaBLE')) assert_not_none( self.ns.find_user_keyword( self.tcf, 'when UK Fromresource from rESOURCE with variaBLE')) assert_not_none( self.ns.find_user_keyword( self.tcf, ' then UK Fromresource from rESOURCE with variaBLE')) assert_not_none( self.ns.find_user_keyword( self.tcf, 'AND UK Fromresource from rESOURCE with variaBLE')) assert_none( self.ns.find_user_keyword( self.tcf, 'given and UK Fromresource from rESOURCE with variaBLE'))
def test_unsubscribe_all(self): self.plugin.unsubscribe_all() self._unsubscribe_all = False RideTestMessage().publish() RideMessageWithData(data_item='Data', more_data=[1, 2, 3]).publish() assert_none(self.plugin.class_handler_topic) assert_none(self.plugin.string_handler_topic) assert_none(self.plugin.case_insensitive_string_handler_topic) assert_equals(self.plugin.record, {}) assert_equals(self.plugin.count, 0) assert_equals(self.plugin.hierarchy_events, []) assert_false(self.plugin in PUBLISHER._listeners)
def test_unsubscribe_all(self): self.plugin.unsubscribe_all() self._unsubscribe_all = False RideTestMessage().publish() RideMessageWithData(data_item='Data', more_data=[1,2,3]).publish() assert_none(self.plugin.class_handler_topic) assert_none(self.plugin.string_handler_topic) assert_none(self.plugin.case_insensitive_string_handler_topic) assert_equals(self.plugin.record, {}) assert_equals(self.plugin.count, 0) assert_equals(self.plugin.hierarchy_events, []) assert_false(self.plugin in PUBLISHER._listeners)
def test_name_from_test_case_file(self): assert_none(self._get_userlibrary().name)
def test_get_set_del_non_ascii_vars(self): set_env_var(NON_ASCII_VAR, NON_ASCII_VAL) assert_equal(get_env_var(NON_ASCII_VAR), NON_ASCII_VAL) assert_equal(del_env_var(NON_ASCII_VAR), NON_ASCII_VAL) assert_none(get_env_var(NON_ASCII_VAR))
def test_get_env_var(self): assert_not_none(get_env_var('PATH')) assert_equal(get_env_var(TEST_VAR), TEST_VAL) assert_none(get_env_var('NoNeXiStInG')) assert_equal(get_env_var('NoNeXiStInG', 'default'), 'default')
def test_unsubscribe_with_string(self): self.plugin.unsubscribe(self.plugin.OnTestEventString, 'ride.test') RideTestMessage().publish() assert_none(self.plugin.string_handler_topic)
def test_file_with_invalid_path(self): imp = Resource(ParentMock(), '${kumikameli}') assert_none(self._res_cache.get_resource(imp.directory, imp.name))
def test_find_user_keyword_name_normalized(self): assert_not_none(self.ns.find_user_keyword(self.tcf, 'UK Fromresource from rESOURCE with variaBLE')) assert_none(self.ns.find_user_keyword(self.tcf, 'Copy List'))
def test_find_user_keyword_name_normalized(self): assert_not_none( self.ns.find_user_keyword( self.tcf, 'UK Fromresource from rESOURCE with variaBLE')) assert_none(self.ns.find_user_keyword(self.tcf, 'Copy List'))
def test_unsubscribe_with_string_is_case_insensitive(self): self.plugin.unsubscribe(self.plugin.OnTestEventStringWrongCase, 'RiDe.TEst') RideTestMessage().publish() assert_none(self.plugin.case_insensitive_string_handler_topic)
def test_get_env_var(self): assert_not_none(get_env_var("PATH")) assert_equals(get_env_var(TEST_VAR), TEST_VAL) assert_none(get_env_var("NoNeXiStInG")) assert_equals(get_env_var("NoNeXiStInG", "default"), "default")
def test_creating_separator(self): item = PopupMenuItem('---') assert_equals(item.name, '---') assert_none(item.callable)
def test_loading_invalid_resource(self): assert_none(self.ctrl.load_resource('invalid', self.load_observer)) assert_equals(self.load_observer.message, "Invalid resource file 'invalid'.") self._test_listeners([], [])
def test_assert_none(self): assert_none(None) assert_raises_with_msg(AE, "message: 'Not None' is not None", assert_none, 'Not None', 'message') assert_raises_with_msg(AE, "message", assert_none, 'Not None', 'message', False)
def test_name_from_test_case_file(self): assert_none(self._get_userlibrary('NOT_RESOURCE').name)
def test_get_registered_name(self): self._test('&File', '&File') for name in 'F&ile', 'File', '&File', 'FI&LE', 'fil&e', 'file': assert_equals(self._nb.get_registered_name(name), '&File') assert_none(self._nb.get_registered_name('Non Existing'))
def test_given_when_then_and_aliases(self): assert_not_none(self.ns.find_user_keyword(self.tcf, ' Given UK Fromresource from rESOURCE with variaBLE')) assert_not_none(self.ns.find_user_keyword(self.tcf, 'when UK Fromresource from rESOURCE with variaBLE')) assert_not_none(self.ns.find_user_keyword(self.tcf, ' then UK Fromresource from rESOURCE with variaBLE')) assert_not_none(self.ns.find_user_keyword(self.tcf, 'AND UK Fromresource from rESOURCE with variaBLE')) assert_none(self.ns.find_user_keyword(self.tcf, 'given and UK Fromresource from rESOURCE with variaBLE'))
def test_del_env_var(self): old = del_env_var(TEST_VAR) assert_none(os.getenv(TEST_VAR)) assert_equal(old, TEST_VAL) assert_none(del_env_var(TEST_VAR))
def test_get_link_returns_none_when_no_match(self): link = TagStatLink('smoke', 'http://tobacco.com', 'Lung cancer') for tag in ['foo', 'b a r', 's moke']: assert_none(link.get_link(tag))
def test_get_setup(self): assert_none(Keywords().setup) setup = Keyword(type='setup') kws = Keywords(keywords=[setup, Keyword(), Keyword()]) assert_true(kws.setup is setup)
def _verify_import_reference_is_not_resolved(self): assert_none(self.import_setting.get_imported_controller())
def test_init(self): assert_none(self.tcf.source) assert_true(isinstance(self.tcf.setting_table, TestCaseFileSettingTable)) assert_true(isinstance(self.tcf.variable_table, VariableTable)) assert_true(isinstance(self.tcf.testcase_table, TestCaseTable)) assert_true(isinstance(self.tcf.keyword_table, KeywordTable))
def test_invalid_argument(self): arg = parse_argument('${my invalid') assert_none(arg)
def test_no_cell_info_if_no_data(self): assert_none(self.test.get_cell_info(0, 0)) assert_none(self.test.get_cell_info(0, 1)) assert_none(self.test.get_cell_info(0, 2)) assert_none(self.test.get_cell_info(0, 3))