-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathports_test.py
73 lines (55 loc) · 1.91 KB
/
ports_test.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
import os
from testify import *
from blueox import ports
class DefaultHostTest(TestCase):
def test_none(self):
host = ports._default_host(None, 'localhost', 123)
hostname, port = host.split(':')
assert_equal(hostname, 'localhost')
assert_equal(port, '123')
def test_host(self):
host = ports._default_host('master', 'localhost', 123)
hostname, port = host.split(':')
assert_equal(hostname, 'master')
assert_equal(port, '123')
def test_explicit(self):
host = ports._default_host('master:1234', 'localhost', 123)
hostname, port = host.split(':')
assert_equal(hostname, 'master')
assert_equal(port, '1234')
class DefaultControlHost(TestCase):
@teardown
def clear_env(self):
try:
del os.environ['BLUEOX_CLIENT_HOST']
except KeyError:
pass
def test_emtpy(self):
host = ports.default_control_host()
assert_equal(host, "127.0.0.1:3513")
def test_env(self):
os.environ['BLUEOX_CLIENT_HOST'] = 'master'
host = ports.default_control_host()
assert_equal(host, "master:3513")
def test_env_port(self):
os.environ['BLUEOX_CLIENT_HOST'] = 'master:123'
host = ports.default_control_host()
assert_equal(host, "master:123")
class DefaultCollectHost(TestCase):
@teardown
def clear_env(self):
try:
del os.environ['BLUEOX_HOST']
except KeyError:
pass
def test_emtpy(self):
host = ports.default_collect_host()
assert_equal(host, "127.0.0.1:3514")
def test_env(self):
os.environ['BLUEOX_HOST'] = 'master'
host = ports.default_collect_host()
assert_equal(host, "master:3514")
def test_env_port(self):
os.environ['BLUEOX_HOST'] = 'master:123'
host = ports.default_collect_host()
assert_equal(host, "master:123")