Skip to content

Commit

Permalink
mode default_config.toml to app/src/cnf/
Browse files Browse the repository at this point in the history
  • Loading branch information
s-allius committed Dec 23, 2024
1 parent b16a8b5 commit 68067d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions app/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def ConfigComplete():
}

def test_default_config():
Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
validated = Config.def_config
assert validated == {'gen3plus': {'at_acl': {'mqtt': {'allow': ['AT+'], 'block': []}, 'tsun': {'allow': ['AT+Z', 'AT+UPURL', 'AT+SUPDATE'], 'block': []}}}, 'tsun': {'enabled': True, 'host': 'logger.talent-monitoring.com', 'port': 5005}, 'solarman': {'enabled': True, 'host': 'iot.talent-monitoring.com', 'port': 10000}, 'mqtt': {'host': 'mqtt', 'port': 1883, 'user': None, 'passwd': None}, 'ha': {'auto_conf_prefix': 'homeassistant', 'discovery_prefix': 'homeassistant', 'entity_prefix': 'tsun', 'proxy_node_id': 'proxy', 'proxy_unique_id': 'P170000000000001'},
'inverters': {
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_full_config(ConfigComplete):
def test_read_empty(ConfigDefault):
test_buffer.rd = ""

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand All @@ -216,14 +216,14 @@ def test_no_file():
assert defcnf == None

def test_no_file2():
Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
assert Config.err == None
ConfigReadToml("_no__file__no_")
err = Config.get_error()
assert err == None

def test_invalid_filename():
Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
assert Config.err == None
ConfigReadToml(None)
err = Config.get_error()
Expand All @@ -232,7 +232,7 @@ def test_invalid_filename():
def test_read_cnf1():
test_buffer.rd = "solarman.enabled = false"

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_read_cnf1():
def test_read_cnf2():
test_buffer.rd = "solarman.enabled = 'FALSE'"

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_read_cnf2():
def test_read_cnf3(ConfigDefault):
test_buffer.rd = "solarman.port = 'FALSE'"

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand All @@ -334,7 +334,7 @@ def test_read_cnf3(ConfigDefault):
def test_read_cnf4():
test_buffer.rd = "solarman.port = 5000"

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand Down Expand Up @@ -377,7 +377,7 @@ def test_read_cnf4():
def test_read_cnf5():
test_buffer.rd = "solarman.port = 1023"

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand All @@ -386,7 +386,7 @@ def test_read_cnf5():
def test_read_cnf6():
test_buffer.rd = "solarman.port = 65536"

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadToml("config/config.toml")
err = Config.get_error()
Expand Down
2 changes: 1 addition & 1 deletion app/tests/test_config_read_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_extend_key():
assert conf == {'': 'testuser'}

def test_read_env_config():
Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
assert Config.get('mqtt') == {'host': 'mqtt', 'port': 1883, 'user': None, 'passwd': None}
for _ in patch_getenv():

Expand Down
10 changes: 5 additions & 5 deletions app/tests/test_config_read_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def ConfigTomlEmpty():
def test_no_config(ConfigDefault):
test_buffer.rd = "" # empty buffer, no json

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadJson()
err = Config.get_error()
Expand All @@ -96,7 +96,7 @@ def test_no_config(ConfigDefault):
def test_no_file(ConfigDefault):
test_buffer.rd = "" # empty buffer, no json

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadJson("_no__file__no_")
err = Config.get_error()
Expand All @@ -108,7 +108,7 @@ def test_no_file(ConfigDefault):
def test_invalid_filename(ConfigDefault):
test_buffer.rd = "" # empty buffer, no json

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadJson(None)
err = Config.get_error()
Expand Down Expand Up @@ -340,7 +340,7 @@ def test_cnv6():
def test_empty_config(ConfigDefault):
test_buffer.rd = "{}" # empty json

Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadJson()
err = Config.get_error()
Expand Down Expand Up @@ -401,7 +401,7 @@ def test_full_config(ConfigComplete):
]
}
"""
Config.init(ConfigReadToml("app/config/default_config.toml"))
Config.init(ConfigReadToml("app/src/cnf/default_config.toml"))
for _ in patch_open():
ConfigReadJson()
err = Config.get_error()
Expand Down

0 comments on commit 68067d5

Please sign in to comment.