def test_search(self): """Test that ldap is correctly queried.""" test_query = "äüáíðáßðöó" attr = [ 'cn', 'swissEduPersonMatriculationNumber', 'givenName', 'sn', 'swissEduPersonGender', 'departmentNumber', 'ou' ] mock_results = [1, 2, 3] # Mock ldap query mock_search = MagicMock(return_value=mock_results) self.app.config['ldap_connector'].search = mock_search # Mock _process_data to check results with patch('amivapi.ldap._process_data') as mock_filter: with self.app.app_context(): result = ldap._search(test_query) # Verify correct query mock_search.assert_called_with(test_query, attributes=attr) # Assert _process_data is called with ldap results for ind, _ in enumerate(result): mock_filter.assert_called_with(mock_results[ind])
def test_search(self): """Test that ldap is correctly queried.""" test_query = "äüáíðáßðöó" attr = [ 'cn', 'swissEduPersonMatriculationNumber', 'givenName', 'sn', 'swissEduPersonGender', 'ou', 'departmentNumber', 'description', ] mock_results = [1, 2, 3] # Mock ldap query mock_search = MagicMock(return_value=mock_results) self.app.config['ldap_connector'].search = mock_search # Mock _process_data to check results with patch('amivapi.ldap._process_data') as mock_filter: with self.app.app_context(): result = ldap._search(test_query) # Verify correct query mock_search.assert_called_with(test_query, attributes=attr) # Assert _process_data is called with ldap results for ind, _ in enumerate(result): mock_filter.assert_called_with(mock_results[ind])