test: Prevent settings from exiting due to missing system lndmanage conf

This commit is contained in:
3nprob 2022-05-01 21:52:27 +09:00
parent 9d09d4b9bc
commit da066c876b
5 changed files with 29 additions and 25 deletions

View file

@ -5,6 +5,12 @@ import time
from typing import List
import unittest
from test.testing_common import (
test_graphs_paths,
SLEEP_SEC_AFTER_REBALANCING,
TestNetwork,
)
from lndmanage.lib.listings import ListChannels
from lndmanage.lib.rebalance import Rebalancer
from lndmanage.lib.exceptions import (
@ -15,12 +21,6 @@ from lndmanage.lib.exceptions import (
OurNodeFailure,
)
from test.testing_common import (
test_graphs_paths,
SLEEP_SEC_AFTER_REBALANCING,
TestNetwork,
)
from lndmanage import settings # needed for side effect configuration

View file

@ -2,9 +2,9 @@ from unittest import TestCase
import sys
import logging
from lndmanage.lib.fee_setting import delta_demand, delta_min, optimization_parameters
from test import testing_common
import testing_common
from lndmanage.lib.fee_setting import delta_demand, delta_min, optimization_parameters
testing_common.logger.addHandler(logging.StreamHandler(sys.stdout))

View file

@ -3,13 +3,13 @@ import asyncio
import time
from unittest import TestCase
from lndmanage.lib import openchannels
from test.testing_common import (
test_graphs_paths,
TestNetwork,
)
from lndmanage.lib import openchannels
def confirm_transactions(testnet):
for _ in range(6):

View file

@ -3,16 +3,16 @@ import asyncio
import time
from typing import Optional
from lndmanage.lib.rebalance import Rebalancer
from lndmanage.lib.ln_utilities import local_balance_to_unbalancedness
from lndmanage.lib.exceptions import NoRebalanceCandidates
from test.testing_common import (
test_graphs_paths,
SLEEP_SEC_AFTER_REBALANCING,
TestNetwork
)
from lndmanage.lib.rebalance import Rebalancer
from lndmanage.lib.ln_utilities import local_balance_to_unbalancedness
from lndmanage.lib.exceptions import NoRebalanceCandidates
class RebalanceTest(TestNetwork):
"""

View file

@ -3,6 +3,21 @@ import os
import shutil
from unittest import TestCase
# testing base folder
test_dir = os.path.dirname(os.path.realpath(__file__))
bin_dir = os.path.join(test_dir, 'bin')
graph_definitions_dir = os.path.join(test_dir, 'graph_definitions')
test_data_dir = os.path.join(test_dir, 'test_data')
# set lndmanage_home path to be in the test_data folder and make sure the
# directory exists
lndmanage_home = os.path.join(test_data_dir, 'lndmanage')
os.makedirs(lndmanage_home, exist_ok=True)
# create empty config and set env var to not trigger error when importing settings
open(os.path.join(lndmanage_home, 'config.ini'), 'a').close()
os.environ.setdefault('LNDMANAGE_HOME', lndmanage_home)
from lnregtest.lib.network import Network
from lndmanage.lib.node import LndNode
@ -17,17 +32,6 @@ settings.CACHING_RETENTION_MINUTES = 0
# constants for testing
SLEEP_SEC_AFTER_REBALANCING = 2
# testing base folder
test_dir = os.path.dirname(os.path.realpath(__file__))
bin_dir = os.path.join(test_dir, 'bin')
graph_definitions_dir = os.path.join(test_dir, 'graph_definitions')
test_data_dir = os.path.join(test_dir, 'test_data')
# set lndmanage_home path to be in the test_data folder and make sure the
# folder exists
lndmanage_home = os.path.join(test_data_dir, 'lndmanage')
os.makedirs(lndmanage_home, exist_ok=True)
test_graphs_paths = {
'star_ring_3_liquid': os.path.join(
graph_definitions_dir, 'star_ring_3_liquid.py'),