-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_parsing.py
165 lines (149 loc) · 8.29 KB
/
test_parsing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import unittest
from main import SRCDSExporter
class TestParsing(unittest.TestCase):
def setUp(self):
self.exporter = SRCDSExporter()
def test_csgo_status(self):
data = ("hostname: LinuxGSM\n"
"version : 1.36.8.7/13687 895/7436 secure [G:1:2645045]\n"
"udp/ip : 172.16.0.17:27015 (public ip: 141.70.125.15)\n"
"os : Linux\n"
"type : community dedicated\n"
"map : de_mirage\n"
"players : 0 humans, 0 bots (16/0 max) (hibernating)\n"
"\n"
"# userid name uniqueid connected ping loss state rate adr\n"
"#end\n")
server_dict = {}
self.exporter._parse_status(data, server_dict)
self.assertEqual(server_dict["hostname"], "LinuxGSM")
self.assertEqual(server_dict["bots"], "0")
self.assertEqual(server_dict["players"], "0")
self.assertEqual(server_dict["max_players"], "16")
def test_csgo_stats(self):
data = (" CPU NetIn NetOut Uptime Maps FPS Players Svms +-ms ~tick\n"
" 10.0 0.0 0.0 46732 1 64.07 0 5.31 0.08 0.03\n")
server_dict = dict()
self.exporter._parse_stats(data, server_dict)
for key, value in {"CPU": 10, "NetIn": 0, "NetOut": 0, "Uptime": 46732,
"Maps": 1, "FPS": 64.07, "Players": 0, "svarms": 5.31,
"varms": 0.08, "vartick": 0.03}.items():
self.assertEqual(server_dict[key], value)
def test_fof_status(self):
data = ("hostname: LinuxGSM\n"
"version : 468/24 0 secure\n"
"udp/ip : 0.0.0.0:27015 (public ip: 141.70.124.33)\n"
"steamid : [A:1:1510767623:12537] (90125840063167495)\n"
"map : fof_depot at: 0 x, 0 y, 0 z\n"
"tags : \n"
"players : 0 humans, 0 bots (16 max)\n"
"edicts : 606 used of 2048 max\n"
"# userid name uniqueid connected ping loss state adr\n")
server_dict = {}
self.exporter._parse_status(data, server_dict)
self.assertEqual(server_dict["hostname"], "LinuxGSM")
self.assertEqual(server_dict["bots"], "0")
self.assertEqual(server_dict["players"], "0")
self.assertEqual(server_dict["max_players"], "16")
def test_fof_stats(self):
data = ("CPU In_(KB/s) Out_(KB/s) Uptime Map_changes FPS Players Connects\n"
"0.00 0.00 0.00 8 0 66.64 0 0\n")
server_dict = dict()
self.exporter._parse_stats(data, server_dict)
for key, value in {"CPU": 0, "NetIn": 0, "NetOut": 0, "Uptime": 8,
"Maps": 0, "FPS": 66.64, "Players": 0, "Connects": 0}.items():
self.assertEqual(server_dict[key], value)
def test_hl2dm_status(self):
data = ("hostname: LinuxGSM\n"
"version : 4630212/24 4630212 insecure (secure mode enabled, disconnected from Steam3)\n"
"udp/ip : 0.0.0.0:27015\n"
"steamid : not logged in\n"
"map : dm_lockdown at: 0 x, 0 y, 0 z\n"
"tags : alltalk,increased_maxplayers\n"
"players : 0 humans, 0 bots (16 max)\n"
"edicts : 495 used of 2048 max\n"
"# userid name uniqueid connected ping loss state adr\n")
server_dict = {}
self.exporter._parse_status(data, server_dict)
self.assertEqual(server_dict["hostname"], "LinuxGSM")
self.assertEqual(server_dict["bots"], "0")
self.assertEqual(server_dict["players"], "0")
self.assertEqual(server_dict["max_players"], "16")
def test_hl2dm_stats(self):
data = ("CPU In_(KB/s) Out_(KB/s) Uptime Map_changes FPS Players Connects\n"
"0.00 0.00 0.00 0 0 66.70 0 0\n")
server_dict = dict()
self.exporter._parse_stats(data, server_dict)
for key, value in {"CPU": 0, "NetIn": 0, "NetOut": 0, "Uptime": 0,
"Maps": 0, "FPS": 66.70, "Players": 0, "Connects": 0}.items():
self.assertEqual(server_dict[key], value)
def test_tf2_status(self):
data = ("hostname: LinuxGSM\n"
"version : 5063830/24 5063830 insecure (secure mode enabled, disconnected from Steam3)\n"
"udp/ip : 0.0.0.0:27015\n"
"steamid : not logged in\n"
"account : not logged in (No account specified)\n"
"map : cp_badlands at: 0 x, 0 y, 0 z\n"
"tags : cp\n"
"players : 0 humans, 0 bots (16 max)\n"
"edicts : 550 used of 2048 max\n"
"# userid name uniqueid connected ping loss state adr\n")
server_dict = {}
self.exporter._parse_status(data, server_dict)
self.assertEqual(server_dict["hostname"], "LinuxGSM")
self.assertEqual(server_dict["bots"], "0")
self.assertEqual(server_dict["players"], "0")
self.assertEqual(server_dict["max_players"], "16")
def test_tf2_stats(self):
data = ("CPU In_(KB/s) Out_(KB/s) Uptime Map_changes FPS Players Connects\n"
"0.00 0.00 0.00 0 0 66.67 0 0\n")
server_dict = dict()
self.exporter._parse_stats(data, server_dict)
for key, value in {"CPU": 0, "NetIn": 0, "NetOut": 0, "Uptime": 0,
"Maps": 0, "FPS": 66.67, "Players": 0, "Connects": 0}.items():
self.assertEqual(server_dict[key], value)
def test_gmod_status(self):
data = ("hostname: LinuxGSM\n"
"version : 19.02.18/24 7472 insecure (secure mode enabled, disconnected from Steam3)\n"
"udp/ip : 192.0.2.1:27015\n"
"map : gm_construct at: 0 x, 0 y, 0 z\n"
"players : 0 (16 max)\n"
"\n"
"# userid name uniqueid connected ping loss state adr\n")
server_dict = {}
self.exporter._parse_status(data, server_dict)
self.assertEqual(server_dict["hostname"], "LinuxGSM")
self.assertEqual(server_dict["players"], "0")
self.assertEqual(server_dict["max_players"], "16")
def test_gmod_stats(self):
data = ("CPU In_(KB/s) Out_(KB/s) Uptime Map_changes FPS Players Connects\n"
"33.00 0.00 0.00 1 0 66.07 0 0\n")
server_dict = dict()
self.exporter._parse_stats(data, server_dict)
for key, value in {"CPU": 33, "NetIn": 0, "NetOut": 0, "Uptime": 1,
"Maps": 0, "FPS": 66.07, "Players": 0, "Connects": 0}.items():
self.assertEqual(server_dict[key], value)
def test_css_status(self):
data = ("hostname: LinuxGSM\n"
"version : 4630212/24 4630212 insecure (secure mode enabled, disconnected from Steam3)\n"
"udp/ip : 0.0.0.0:27015\n"
"steamid : not logged in\n"
"map : de_dust2 at: 0 x, 0 y, 0 z\n"
"tags :\n"
"players : 0 humans, 0 bots (16 max)\n"
"edicts : 212 used of 2048 max\n"
"# userid name uniqueid connected ping loss state adr\n")
server_dict = {}
self.exporter._parse_status(data, server_dict)
self.assertEqual(server_dict["hostname"], "LinuxGSM")
self.assertEqual(server_dict["players"], "0")
self.assertEqual(server_dict["bots"], "0")
self.assertEqual(server_dict["max_players"], "16")
def test_css_stats(self):
data = ("CPU In_(KB/s) Out_(KB/s) Uptime Map_changes FPS Players Connects\n"
"0.00 0.00 0.00 2 0 66.55 0 0\n")
server_dict = dict()
self.exporter._parse_stats(data, server_dict)
for key, value in {"CPU": 0, "NetIn": 0, "NetOut": 0, "Uptime": 2,
"Maps": 0, "FPS": 66.55, "Players": 0, "Connects": 0}.items():
self.assertEqual(server_dict[key], value)