-
Notifications
You must be signed in to change notification settings - Fork 71
/
test_server.py
162 lines (131 loc) · 4.43 KB
/
test_server.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
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Oliver Ainsworth
from __future__ import (absolute_import,
unicode_literals, print_function, division)
import pytest
import six
import valve.source
import valve.source.a2s
@pytest.srcds_functional(gamedir="tf")
def test_tf2_ping(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
latency = a2s.ping()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert latency > 0
@pytest.srcds_functional(gamedir="tf")
def test_tf2_info(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
info = a2s.info()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert info["app_id"] == 440
assert info["folder"] == "tf"
assert isinstance(info["folder"], six.text_type)
@pytest.srcds_functional(gamedir="tf")
def test_tf2_rules(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
rules = a2s.rules()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
@pytest.srcds_functional(gamedir="cstrike")
def test_css_ping(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
latency = a2s.ping()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert latency > 0
@pytest.srcds_functional(gamedir="cstrike")
def test_css_info(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
info = a2s.info()
except valve.source.NoResponseError:
return
assert info["app_id"] == 240
assert info["folder"] == "cstrike"
assert isinstance(info["folder"], six.text_type)
@pytest.srcds_functional(gamedir="csgo")
def test_csgo_ping(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
latency = a2s.ping()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert latency > 0
@pytest.srcds_functional(gamedir="csgo")
def test_csgo_info(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
info = a2s.info()
except valve.source.NoResponseError:
return
assert info["app_id"] == 730
assert info["folder"] == "csgo"
assert isinstance(info["folder"], six.text_type)
@pytest.srcds_functional(gamedir="dota")
def test_dota2_ping(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
latency = a2s.ping()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert latency > 0
@pytest.srcds_functional(gamedir="dota")
def test_dota2_info(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
info = a2s.info()
except valve.source.NoResponseError:
return
assert info["app_id"] == 570
assert info["folder"] == "dota"
assert isinstance(info["folder"], six.text_type)
@pytest.srcds_functional(gamedir="left4dead")
def test_l4d_ping(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
latency = a2s.ping()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert latency > 0
@pytest.srcds_functional(gamedir="left4dead")
def test_l4d_info(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
info = a2s.info()
except valve.source.NoResponseError:
return
assert info["app_id"] == 500
assert info["folder"] == "left4dead"
assert isinstance(info["folder"], six.text_type)
@pytest.srcds_functional(gamedir="left4dead2")
def test_l4d2_ping(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
latency = a2s.ping()
except valve.source.NoResponseError:
pytest.skip("Timedout waiting for response")
assert latency > 0
@pytest.srcds_functional(gamedir="left4dead2")
def test_l4d2_info(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
info = a2s.info()
except valve.source.NoResponseError:
return
assert info["app_id"] == 550
assert info["folder"] == "left4dead2"
assert isinstance(info["folder"], six.text_type)
# quake live
@pytest.srcds_functional(region='rest', appid='282440')
def test_ql_rules(address):
try:
a2s = valve.source.a2s.ServerQuerier(address)
rules = a2s.rules()
except valve.source.NoResponseError:
return