A Python port of the Invisible Internet Project (I2P)
at main 46 lines 1.4 kB view raw
1"""Tests for configuration pages — TDD: tests before implementation.""" 2 3import pytest 4from i2p_apps.console.app import create_app 5 6 7@pytest.fixture 8def client(): 9 app = create_app({"TESTING": True}) 10 return app.test_client() 11 12 13class TestConfigPage: 14 def test_config_page_renders(self, client): 15 resp = client.get("/config/") 16 assert resp.status_code == 200 17 assert b"html" in resp.data.lower() 18 19 def test_config_network(self, client): 20 resp = client.get("/config/network") 21 assert resp.status_code == 200 22 assert b"Network" in resp.data 23 24 def test_config_security(self, client): 25 resp = client.get("/config/security") 26 assert resp.status_code == 200 27 28 def test_config_logging(self, client): 29 resp = client.get("/config/logging") 30 assert resp.status_code == 200 31 32 def test_config_advanced(self, client): 33 resp = client.get("/config/advanced") 34 assert resp.status_code == 200 35 36 def test_config_post_network(self, client): 37 resp = client.post("/config/network", data={ 38 "i2np.udp.port": "8887", 39 "i2np.ntcp.port": "8887", 40 }) 41 # Should redirect back to config page 42 assert resp.status_code in (200, 302) 43 44 def test_config_unknown_section(self, client): 45 resp = client.get("/config/nonexistent") 46 assert resp.status_code == 404