def test_delete_topic_by_id__http_error_code__raises_api_error(error_code):
    response = Mock()
    response.status_code = error_code

    request_handler = Mock()
    request_handler.delete = Mock(return_value=response)

    client = SubscriptionManagerClient(request_handler=request_handler)

    with pytest.raises(APIError):
        client.delete_topic_by_id(1)
def test_delete_topic():
    sm_client = SubscriptionManagerClient(mock.Mock())

    mock_delete_topic_by_id = mock.Mock()
    sm_client.delete_topic_by_id = mock_delete_topic_by_id

    sm_service = SubscriptionManagerService(sm_client)

    topic = Topic(name='topic', id=1)

    sm_service.delete_topic(topic)

    mock_delete_topic_by_id.assert_called_once_with(topic_id=topic.id)
def test_delete_topic_by_id():
    response = Mock()
    response.status_code = 204
    response.content = {}
    response.json = Mock(return_value={})

    request_handler = Mock()
    request_handler.delete = Mock(return_value=response)

    client = SubscriptionManagerClient(request_handler=request_handler)

    topic = client.delete_topic_by_id(1)

    called_url = request_handler.delete.call_args[0][0]
    assert BASE_URL + 'topics/1' == called_url