def test_create_team_with_id(requests_mock): team = Team( id=1, external_id='testteam1', name='Test Team', short_name='TT', light_crest_url='http://www.images.com/image1.jpg', dark_crest_url='http://www.images.com/image2.jpg', ) resource_client = LiveStyledResourceClient(TEST_API_DOMAIN, 'bar') with pytest.raises(ValueError, match='Cannot create a Team with an ID'): resource_client.create_team(team)
def test_create_team(requests_mock): team = Team.create_new( external_id='testteam1', name='Test Team', short_name='TT', light_crest_url='http://www.images.com/image1.jpg', dark_crest_url='http://www.images.com/image2.jpg' ) mock_responses = ( ('POST', 'https://' + TEST_API_DOMAIN + '/v4/teams', 'mock_responses/ls_api/create_team.json', 200), ) configure_mock_responses(requests_mock, mock_responses, FIXTURES_DIR, CONTENT_TYPE) resource_client = LiveStyledResourceClient(TEST_API_DOMAIN, 'bar') created_team = resource_client.create_team(team) assert created_team assert created_team.id == 999 for request in requests_mock.request_history: if request.method.upper() == 'POST' and request.url == 'https://' + TEST_API_DOMAIN + '/v4/teams': actual_payload = request.json() assert actual_payload == { 'name': 'Test Team', 'shortName': 'TT', 'lightCrestUrl': 'http://www.images.com/image1.jpg', 'darkCrestUrl': 'http://www.images.com/image2.jpg', 'externalId': 'testteam1' }