def test_one_function_is_added_to_function_repo(self): # Arrange module = real('Module') module.id_ = 'fake_file_name' self.model.modules.add(module) function_modeler = FunctionModeler(self.source_code_parser, EntityIdGenerator('.'), self.model) node = MagicMock() node.parent = Mock(spec=astroid.scoped_nodes.Module) node.parent.file = 'fake_file_name' node.lineno = 44 # Act function_modeler.on_function(node) # Assert expected_function = Function('fake_file_name:44', 'fake_function_name', module) self.model.functions.add.assert_called_once_with(expected_function)
def test_one_method_is_added_to_function_repo(self): # Arrange class_mock = real('Class_') class_mock.id_ = 'fake_file_name:33' self.model.classes.add(class_mock) function_modeler = FunctionModeler(self.source_code_parser, EntityIdGenerator('.'), self.model) node = MagicMock() node.parent = Mock(spec=astroid.scoped_nodes.Class) node.parent.parent.file = 'fake_file_name' node.parent.lineno = 33 node.name = 'fake_function_name' node.lineno = 44 # Act function_modeler.on_function(node) # Assert expected_function = Method('fake_file_name:44', 'fake_function_name', class_mock) self.model.functions.add.assert_called_once_with(expected_function)