Also extracts out some common testing infrastructure to make testing APIs easier now using pytest
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import json
|
|
|
|
from mock import patch
|
|
|
|
from data import model
|
|
from endpoints.api import api
|
|
from endpoints.api.test.shared import client_with_identity, conduct_api_call
|
|
from endpoints.api.team import OrganizationTeamSyncing
|
|
from test.test_ldap import mock_ldap
|
|
|
|
TEAM_PARAMS = {'orgname': 'buynlarge', 'teamname': 'owners'}
|
|
|
|
def test_team_syncing(client):
|
|
with mock_ldap() as ldap:
|
|
with patch('endpoints.api.team.authentication', ldap):
|
|
cl = client_with_identity('devtable', client)
|
|
config = {
|
|
'group_dn': 'cn=AwesomeFolk',
|
|
}
|
|
|
|
conduct_api_call(cl, OrganizationTeamSyncing, 'POST', TEAM_PARAMS, config)
|
|
|
|
# Ensure the team is now synced.
|
|
sync_info = model.team.get_team_sync_information(TEAM_PARAMS['orgname'],
|
|
TEAM_PARAMS['teamname'])
|
|
assert sync_info is not None
|
|
assert json.loads(sync_info.config) == config
|
|
|
|
# Remove the syncing.
|
|
conduct_api_call(cl, OrganizationTeamSyncing, 'DELETE', TEAM_PARAMS, None)
|
|
|
|
# Ensure the team is no longer synced.
|
|
sync_info = model.team.get_team_sync_information(TEAM_PARAMS['orgname'],
|
|
TEAM_PARAMS['teamname'])
|
|
assert sync_info is None
|