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
|
#!/usr/bin/python3
import os
import logging
import unittest
from staslib import conf
TEST_DIR = os.path.dirname(__file__)
EXPECTED_DCS = [
{
'subsysnqn': 'nqn.2014-08.org.nvmexpress.discovery',
'traddr': '100.71.103.50',
'transport': 'tcp',
'trsvcid': '8009',
}
]
EXPECTED_IOCS = [
{
'data-digest': False,
'hdr-digest': False,
'subsysnqn': 'nqn.1988-11.com.dell:powerstore:00:2a64abf1c5b81F6C4549',
'traddr': '100.71.103.48',
'transport': 'tcp',
'trsvcid': '4420',
},
{
'data-digest': False,
'hdr-digest': False,
'subsysnqn': 'nqn.1988-11.com.dell:powerstore:00:2a64abf1c5b81F6C4549',
'traddr': '100.71.103.49',
'transport': 'tcp',
'trsvcid': '4420',
},
]
class Test(unittest.TestCase):
"""Unit tests for class NbftConf"""
def test_dir_with_nbft_files(self):
conf.NbftConf.destroy() # Make sure singleton does not exist
with self.assertLogs(logger=logging.getLogger(), level='DEBUG') as captured:
nbft_conf = conf.NbftConf(TEST_DIR)
self.assertNotEqual(-1, captured.records[0].getMessage().find("NBFT location(s):"))
self.assertEqual(nbft_conf.dcs, EXPECTED_DCS)
self.assertEqual(nbft_conf.iocs, EXPECTED_IOCS)
def test_dir_without_nbft_files(self):
conf.NbftConf.destroy() # Make sure singleton does not exist
with self.assertNoLogs(logger=logging.getLogger(), level='DEBUG'):
nbft_conf = conf.NbftConf('/tmp')
self.assertEqual(nbft_conf.dcs, [])
self.assertEqual(nbft_conf.iocs, [])
if __name__ == "__main__":
unittest.main()
|