linux observer
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4import pytest
5
6from solstone_linux.streams import _strip_hostname, stream_name
7
8
9class TestStripHostname:
10 def test_simple(self):
11 assert _strip_hostname("archon") == "archon"
12
13 def test_with_domain(self):
14 assert _strip_hostname("ja1r.local") == "ja1r"
15
16 def test_ip_address(self):
17 assert _strip_hostname("192.168.1.1") == "192-168-1-1"
18
19 def test_fqdn(self):
20 assert _strip_hostname("my.host.example.com") == "my"
21
22 def test_empty(self):
23 assert _strip_hostname("") == ""
24
25
26class TestStreamName:
27 def test_host_only(self):
28 assert stream_name(host="archon") == "archon"
29
30 def test_host_with_qualifier(self):
31 assert stream_name(host="archon", qualifier="tmux") == "archon.tmux"
32
33 def test_host_no_qualifier(self):
34 # Linux observer uses host without qualifier
35 assert stream_name(host="archon") == "archon"
36
37 def test_observer(self):
38 assert stream_name(observer="desktop") == "desktop"
39
40 def test_rejects_empty(self):
41 with pytest.raises(ValueError):
42 stream_name()
43
44 def test_rejects_invalid_chars(self):
45 with pytest.raises(ValueError):
46 stream_name(host="!invalid")