Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nginx-redirector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
nginx-redirector
Commits
f1816019
Commit
f1816019
authored
Jun 05, 2021
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests
parent
82d03454
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
27 deletions
+15
-27
redirector_test.py
redirector/tests/redirector_test.py
+15
-27
No files found.
redirector/tests/redirector_test.py
View file @
f1816019
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
=
Test
Redirector
()
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
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment