Skip to content

Commit 7580013

Browse files
author
Konstantin Wolff
committed
changed nose tests to class based to make advantage of the setup_class function
1 parent ecb58b4 commit 7580013

File tree

2 files changed

+790
-806
lines changed

2 files changed

+790
-806
lines changed

miniprobe/tests/test_miniprobe.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,33 @@
33
from nose.tools import *
44
from miniprobe import miniprobe
55

6-
config = {}
7-
config['gid'] = 'testgid'
8-
config['key'] = 'testkey'
9-
config['protocol'] = 'testprotocol'
10-
config['name'] = 'testname'
11-
config['baseinterval'] = 'testbaseinterval'
12-
config['server'] = 'testserver'
13-
config['port'] = 'testport'
6+
class TestMiniProbe():
7+
@classmethod
8+
def setup_class(cls):
9+
cls.config = {}
10+
cls.mp = miniprobe.MiniProbe()
11+
cls.config['gid'] = 'testgid'
12+
cls.config['key'] = 'testkey'
13+
cls.config['protocol'] = 'testprotocol'
14+
cls.config['name'] = 'testname'
15+
cls.config['baseinterval'] = 'testbaseinterval'
16+
cls.config['server'] = 'testserver'
17+
cls.config['port'] = 'testport'
1418

15-
def test_miniprobe_hash_access_key():
16-
"""miniprobe returns the correct hash_access_key"""
17-
test_hash_access_key = miniprobe.MiniProbe()
18-
assert_equal(test_hash_access_key.hash_access_key('test'), 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')
19+
def test_miniprobe_hash_access_key(self):
20+
"""miniprobe returns the correct hash_access_key"""
21+
test_hash_access_key = self.mp
22+
assert_equal(test_hash_access_key.hash_access_key(self.config['key']), '913a73b565c8e2c8ed94497580f619397709b8b6')
1923

20-
def test_miniprobe_create_parameters():
21-
"""miniprobe returns the correct create_parameters"""
22-
test_create_parameters = miniprobe.MiniProbe()
23-
assert_equal(test_create_parameters.create_parameters(config, '{}'), {'gid': 'testgid', 'protocol': 'testprotocol', 'key': '913a73b565c8e2c8ed94497580f619397709b8b6'})
24-
assert_equal(test_create_parameters.create_parameters(config, '{}', 'announce'), {'protocol': 'testprotocol', 'name': 'testname', 'gid': 'testgid', 'baseinterval': 'testbaseinterval', 'key': '913a73b565c8e2c8ed94497580f619397709b8b6', 'sensors': '{}'})
24+
def test_miniprobe_create_parameters(self):
25+
"""miniprobe returns the correct create_parameters"""
26+
test_create_parameters = self.mp
27+
assert_equal(test_create_parameters.create_parameters(self.config, '{}'), {'gid': 'testgid', 'protocol': 'testprotocol', 'key': '913a73b565c8e2c8ed94497580f619397709b8b6'})
28+
assert_equal(test_create_parameters.create_parameters(self.config, '{}', 'announce'), {'protocol': 'testprotocol', 'name': 'testname', 'gid': 'testgid', 'baseinterval': 'testbaseinterval', 'key': '913a73b565c8e2c8ed94497580f619397709b8b6', 'sensors': '{}'})
2529

26-
def test_miniprobe_create_url():
27-
"""miniprobe returns the correct create_url"""
28-
test_create_url = miniprobe.MiniProbe()
29-
assert_equal(test_create_url.create_url(config), 'No method given')
30-
assert_equal(test_create_url.create_url(config, 'test'), 'https://testserver:testport/probe/test')
31-
assert_equal(test_create_url.create_url(config, 'data'), 'https://testserver:testport/probe/data?gid=testgid&protocol=testprotocol&key=913a73b565c8e2c8ed94497580f619397709b8b6')
30+
def test_miniprobe_create_url(self):
31+
"""miniprobe returns the correct create_url"""
32+
test_create_url = self.mp
33+
assert_equal(test_create_url.create_url(self.config), 'No method given')
34+
assert_equal(test_create_url.create_url(self.config, 'test'), 'https://testserver:testport/probe/test')
35+
assert_equal(test_create_url.create_url(self.config, 'data'), 'https://testserver:testport/probe/data?gid=testgid&protocol=testprotocol&key=913a73b565c8e2c8ed94497580f619397709b8b6')

0 commit comments

Comments
 (0)