Skip to content

Commit

Permalink
Update test_directions_reduction.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 15, 2024
1 parent d3006bd commit 9b195e9
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions kyu_5/directions_reduction/test_directions_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import unittest
import allure
from utils.log_func import print_log
from parameterized import parameterized
from kyu_5.directions_reduction.directions_reduction \
import dir_reduc

Expand All @@ -29,7 +30,25 @@
class DirectionsReductionTestCase(unittest.TestCase):
"""Testing dir_reduc function."""

def test_directions_reduction(self):
@parameterized.expand([
(["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"],
['WEST']),
(["NORTH", "WEST", "SOUTH", "EAST"],
["NORTH", "WEST", "SOUTH", "EAST"]),
(['NORTH', 'EAST', 'NORTH', 'EAST', 'WEST', 'WEST', 'EAST',
'EAST', 'WEST', 'SOUTH'],
['NORTH', 'EAST']),
(['EAST', 'NORTH', 'SOUTH', 'NORTH', 'SOUTH', 'SOUTH', 'SOUTH',
'SOUTH', 'NORTH', 'SOUTH', 'SOUTH', 'EAST', 'SOUTH', 'SOUTH',
'NORTH', 'NORTH', 'SOUTH', 'WEST', 'NORTH', 'EAST', 'WEST',
'WEST', 'WEST', 'EAST', 'SOUTH', 'SOUTH'],
['EAST', 'SOUTH', 'SOUTH', 'SOUTH', 'SOUTH', 'EAST', 'SOUTH',
'WEST', 'NORTH', 'WEST', 'SOUTH', 'SOUTH']),
(['WEST', 'NORTH', 'EAST', 'EAST', 'EAST', 'EAST', 'WEST', 'WEST',
'WEST', 'WEST', 'NORTH', 'NORTH', 'SOUTH', 'EAST'],
['WEST', 'NORTH', 'NORTH', 'EAST'])
])
def test_directions_reduction(self, test_array, expected):
"""
dir_reduc function test suite.
Expand Down Expand Up @@ -59,35 +78,10 @@ def test_directions_reduction(self):
"strings and returns an array of strings with the needless "
"directions removed (W<->E or S<->N side by side).</p>")
# pylint: enable-msg=R0801
test_data: tuple = (
(["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"],
['WEST']),
(["NORTH", "WEST", "SOUTH", "EAST"],
["NORTH", "WEST", "SOUTH", "EAST"]),
(['NORTH', 'EAST', 'NORTH', 'EAST', 'WEST', 'WEST', 'EAST',
'EAST', 'WEST', 'SOUTH'],
['NORTH', 'EAST']),
(['EAST', 'NORTH', 'SOUTH', 'NORTH', 'SOUTH', 'SOUTH', 'SOUTH',
'SOUTH', 'NORTH', 'SOUTH', 'SOUTH', 'EAST', 'SOUTH', 'SOUTH',
'NORTH', 'NORTH', 'SOUTH', 'WEST', 'NORTH', 'EAST', 'WEST',
'WEST', 'WEST', 'EAST', 'SOUTH', 'SOUTH'],
['EAST', 'SOUTH', 'SOUTH', 'SOUTH', 'SOUTH', 'EAST', 'SOUTH',
'WEST', 'NORTH', 'WEST', 'SOUTH', 'SOUTH']),
(['WEST', 'NORTH', 'EAST', 'EAST', 'EAST', 'EAST', 'WEST', 'WEST',
'WEST', 'WEST', 'NORTH', 'NORTH', 'SOUTH', 'EAST'],
['WEST', 'NORTH', 'NORTH', 'EAST']))

for d in test_data:
test_array = d[0].copy()
expected = d[1]
result = dir_reduc(d[0])

with allure.step(f"Enter test data ({test_array}) "
f"and verify the output ({result}) "
f"vs expected ({expected})"):

print_log(test_array=test_array,
result=result,
expected=expected)

self.assertListEqual(expected, result)
result = dir_reduc(test_array)
with allure.step(f"Enter test data ({test_array}) "
f"and verify the output ({result}) "
f"vs expected ({expected})"):
print_log(test_array=test_array, result=result, expected=expected)
self.assertListEqual(expected, result)

0 comments on commit 9b195e9

Please sign in to comment.