Update tests

parent 82d03454
import unittest
from redirector.tests.utils import get_abs_path, get_rel_path
from redirector.conf.config import Config
from redirector.redirector import *
from redirector.utils import generators
from redirector.utils import parser
from redirector.utils.const import MAPS_DIR, CONFIG_DIR, CONFIG
class TestGenerator(generators.Generator):
def get_conf_dirs(self):
config = Config()
abs_conf_path = get_abs_path('test.ini')
config.read_config(abs_conf_path)
maps_dir = get_rel_path(config.get_default_dir('MAPS_DIR'))
config_dir = get_rel_path(config.get_default_dir('CONFIG_DIR'))
return maps_dir, config_dir
class TestRedirector(Redirector):
def __init__(self, logger=None):
self.parser = parser.ConfigReader(logger=logger)
self.generator = TestGenerator()
class EqualRedirectorTest(unittest.TestCase):
def setUp(self):
self.redirector = TestRedirector()
self.redirector = Redirector()
def test_equal_map(self):
abs_yaml_path = get_abs_path('test.yaml')
abs_yaml_path = get_abs_path(CONFIG)
abs_test_path = get_abs_path('test.map')
abs_res_conf_path = get_rel_path('nginx_test_case/location-includes/test.conf')
abs_res_conf_path = get_rel_path(f"{CONFIG_DIR}/test.conf")
res_conf_file = open(abs_res_conf_path, 'r')
res_conf_lines = []
......@@ -44,9 +26,12 @@ class EqualRedirectorTest(unittest.TestCase):
res_conf_file.close()
maps_dir = get_rel_path('nginx_test_case/maps')
abs_res_map_paths = ['{}/test.map'.format(maps_dir), '{}/test_permanent_options.map'.format(maps_dir),\
'{}/test_status=301_options.map'.format(maps_dir)]
maps_dir = get_rel_path(MAPS_DIR)
abs_res_map_paths = [
f"{maps_dir}/test.map",
f"{maps_dir}/test_permanent_options.map",
f"{maps_dir}/test_status=301_options.map"
]
res_map_lines = []
......@@ -72,8 +57,11 @@ class EqualRedirectorTest(unittest.TestCase):
test_conf_file.close()
test_maps_dir = get_rel_path('nginx/maps')
abs_test_map_paths = ['{}/test.map'.format(test_maps_dir), '{}/test_permanent_options.map'.format(test_maps_dir),\
'{}/test_status=301_options.map'.format(test_maps_dir)]
abs_test_map_paths = [
f"{test_maps_dir}/test.map",
f"{test_maps_dir}/test_permanent_options.map",
f"{test_maps_dir}/test_status=301_options.map"
]
test_map_lines = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment