-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy path_testConf.py
More file actions
71 lines (57 loc) · 1.75 KB
/
_testConf.py
File metadata and controls
71 lines (57 loc) · 1.75 KB
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
# -*- coding: utf-8 -*-
"""
Internal module
Used to read the channelfinderapi.conf file
example file
cat ~/channelfinderapi.conf
[DEFAULT]
BaseURL=http://localhost:8080/ChannelFinder
username=MyUserName
password=MyPassword
"""
import os.path
import unittest
from testcontainers.compose import DockerCompose
from configparser import ConfigParser
def channelFinderDocker():
return DockerCompose("test", compose_file_name="docker-compose.yml")
class ChannelFinderClientTestCase(unittest.TestCase):
channelFinderCompose = None
@classmethod
def setUpClass(cls) -> None:
cls.channelFinderCompose = channelFinderDocker()
cls.channelFinderCompose.start()
cls.channelFinderCompose.wait_for(_testConf.get("DEFAULT", "BaseURL"))
return super().setUpClass()
@classmethod
def tearDownClass(cls) -> None:
if cls.channelFinderCompose is not None:
cls.channelFinderCompose.stop()
return super().tearDownClass()
def __loadConfig():
dflt = {
"BaseURL": "http://localhost:8080/ChannelFinder",
"username": "admin",
"password": "adminPass",
"owner": "cf-update",
"verify_ssl": "False",
"channelOwner": "cf-channels",
"channelUsername": "admin",
"channelPassword": "adminPass",
"propOwner": "cf-properties",
"propUsername": "admin",
"propPassword": "adminPass",
"tagOwner": "cf-tags",
"tagUsername": "admin",
"tagPassword": "adminPass",
}
cf = ConfigParser(defaults=dflt)
cf.read(
[
"/etc/channelfinderapi.conf",
os.path.expanduser("~/channelfinderapi.conf"),
"channelfinderapi.conf",
]
)
return cf
_testConf = __loadConfig()