def test_id_delete_technology(client):
    python_data = {
        'name': 'Python',
        'description': 'Object oriented programming language',
    }
    elixir_data = {
        'name': 'Elixir',
        'description': 'Functional programming language',
    }
    client.post(
        '/technologies',
        json=python_data,
        headers=auth_header_with_all_permissions
    )
    create_resp = client.post(
        '/technologies',
        json=elixir_data,
        headers=auth_header_with_all_permissions
    )
    create_resp_data = create_resp.get_json()
    resp = client.delete(
        create_resp_data['href'],
        headers=auth_header_with_all_permissions
    )
    assert '204' in resp.status
    assert len(Technology.query.all()) == 1
def test_it_returns_404_if_deleted_technology_does_not_exis(client):
    resp = client.delete(
        '/technologies/1',
        headers=auth_header_with_all_permissions
    )
    resp_data = resp.get_json()
    assert '404' in resp.status
    assert resp_data['error'] == 404
    assert 'Not found' in resp_data['message']
def test_it_deletes_author(client):
    technology_id = create_technology_and_return_id(client, 'Python')
    data = {
        'name': 'Paweł',
        'surname': 'Niesiołowski',
        'email': '*****@*****.**',
        'technologies': [technology_id],
    }
    created_author_data = client.post(
        '/authors',
        json=data,
        headers=auth_header_with_all_permissions
    ).get_json()
    authors_before_delete = Author.query.all()
    resp = client.delete(
        created_author_data['href'],
        headers=auth_header_with_all_permissions
    )
    authors_after_delete = Author.query.all()
    assert '204' in resp.status
    assert len(authors_before_delete) == 1
    assert len(authors_after_delete) == 0