A Python port of the Invisible Internet Project (I2P)
1"""Tests for RouterContext adapter — TDD: tests before implementation."""
2
3import pytest
4from i2p_apps.console.context import ConsoleContext
5
6
7class TestConsoleContext:
8 def test_creation(self):
9 ctx = ConsoleContext()
10 assert ctx is not None
11
12 def test_uptime(self):
13 ctx = ConsoleContext()
14 assert ctx.uptime_seconds >= 0
15
16 def test_version(self):
17 ctx = ConsoleContext()
18 assert isinstance(ctx.version, str)
19 assert len(ctx.version) > 0
20
21 def test_status(self):
22 ctx = ConsoleContext()
23 status = ctx.status
24 assert "state" in status
25 assert "uptime" in status
26 assert "version" in status
27
28 def test_network_status(self):
29 ctx = ConsoleContext()
30 net = ctx.network_status
31 assert "active_peers" in net
32 assert "known_routers" in net
33 assert isinstance(net["active_peers"], int)
34
35 def test_get_property(self):
36 ctx = ConsoleContext()
37 ctx.set_property("test.key", "test_value")
38 assert ctx.get_property("test.key") == "test_value"
39
40 def test_get_property_default(self):
41 ctx = ConsoleContext()
42 assert ctx.get_property("nonexistent", "default") == "default"