:param tool_name: the name of the tool to check existence for :type tool_name: str :return: `True` if the tool exists, `False` otherwise :rtype: boolean """ for tool in GNAThub.Tool.list(): if tool.name == tool_name: return True return False # Check tool exists assertTrue(contains(TOOL)) tool = GNAThub.Tool(TOOL) # Check that rules were created rules = [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id] assertNotEmpty(rules) # Check that messages were recorded assertNotEmpty( [msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Purge the database GNAThub.Tool.clear_references(TOOL) # Check that messages were deleted assertEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Check that rules were deleted assertEmpty( [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id]) # Check that tool was deleted assertFalse(contains(TOOL))
assertIsNotNone(resource) tool = GNAThub.Tool('test-tool') assertIsNotNone(tool) rule = GNAThub.Rule('test-rule', 'test-rule-name', GNAThub.RULE_KIND, tool) assertIsNotNone(rule) prop0 = GNAThub.Property('test-prop-0', 'test-prop-name-0') assertIsNotNone(prop0) prop1 = GNAThub.Property('test-prop-1', 'test-prop-name-1') assertIsNotNone(prop1) msg0 = GNAThub.Message(rule, 'test message', properties=None) assertIsNotNone(msg0) assertEmpty(msg0.get_properties()) msg1 = GNAThub.Message(rule, 'test message', properties=[prop0, prop1]) assertIsNotNone(msg1) for msg in msg0, msg1: resource.add_message(msg) assertNotEmpty(msg1.get_properties()) msg1_prop0 = msg1.get_properties()[0] assertEqual(prop0.name, msg1_prop0.name) assertEqual(prop0.identifier, msg1_prop0.identifier) with assertRaises(Exception): GNAThub.Message(rule, 'test message', properties=0) with assertRaises(Exception): GNAThub.Message(rule, 'test message', properties=prop0)
:param tool_name: the name of the tool to check existence for :type tool_name: str :return: `True` if the tool exists, `False` otherwise :rtype: boolean """ for tool in GNAThub.Tool.list(): if tool.name == tool_name: return True return False # Check tool exists assertTrue(contains(TOOL)) tool = GNAThub.Tool(TOOL) # Check that rules were created rules = [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id] assertNotEmpty(rules) # Check that messages were recorded assertNotEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Purge the database GNAThub.Tool.clear_references(TOOL) # Check that messages were deleted assertEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Check that rules were deleted assertEmpty( [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id]) # Check that tool was deleted assertFalse(contains(TOOL))
"""Check that LALmetric executed correctly.""" import GNAThub from support.asserts import assertIn, assertNotEmpty assertIn('lalmetric', [tool.name for tool in GNAThub.Tool.list()]) lalmetric = GNAThub.Tool('lalmetric') lalmetric_rules = [ rule.id for rule in GNAThub.Rule.list() if rule.tool_id == lalmetric.id ] assertNotEmpty(lalmetric_rules) assertNotEmpty( [msg for msg in GNAThub.Message.list() if msg.rule_id in lalmetric_rules] )