-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) 2015 The Pycroft Authors. See the AUTHORS file. | ||
# This file is part of the Pycroft project and licensed under the terms of | ||
# the Apache License, Version 2.0. See the LICENSE file for details. | ||
|
||
import pytest | ||
from flask import url_for | ||
|
||
from pycroft.model.host import Host, Interface | ||
from tests import factories as f | ||
|
||
from .assertions import TestClient | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def client(module_test_client: TestClient) -> TestClient: | ||
return module_test_client | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def host(module_session) -> Host: | ||
return f.HostFactory(interface=None) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def interface(module_session) -> Interface: | ||
return f.InterfaceFactory(host=host) | ||
|
||
|
||
pytestmark = pytest.mark.usefixtures("admin_logged_in") | ||
|
||
|
||
@pytest.mark.usefixtures("session") | ||
class TestInterfaceDelete: | ||
def test_delete_nonexistent_interface(self, client): | ||
client.assert_url_response_code( | ||
url_for("host.interface_delete", interface_id=999), code=404 | ||
) | ||
|
||
def test_delete_interface_get(self, client, interface): | ||
with client.renders_template("generic_form.html"): | ||
client.assert_url_ok( | ||
url_for("host.interface_delete", interface_id=interface.id) | ||
) | ||
|
||
def test_delete_interface_post(self, session, client, interface): | ||
with client.flashes_message("Interface.*gelöscht", category="success"): | ||
client.assert_url_redirects( | ||
url_for("host.interface_delete", interface_id=interface.id), | ||
method="POST", | ||
) | ||
session.refresh(host) | ||
assert interface not in host.interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters