Skip to content

Commit

Permalink
# Who likes it
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 18, 2024
1 parent 168a6b0 commit cd22053
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions kyu_6/who_likes_it/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Who likes it."""
5 changes: 4 additions & 1 deletion kyu_6/who_likes_it/likes_function.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Who likes it?
Solution for -> Who likes it?.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def likes(names: list) -> str:
"""
Likes.
A function which must take in input array, containing the
names of people who like an item. It must return the
display text.
Expand Down
33 changes: 17 additions & 16 deletions kyu_6/who_likes_it/test_likes_function.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> likes function
Test for -> likes function.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_6.who_likes_it.likes_function import likes

Expand Down Expand Up @@ -35,9 +37,18 @@ class LikesTestCase(unittest.TestCase):
of people who like an item. It must return the display text.
For 4 or more names, the number in and 2 others simply increases.
"""
def test_likes_function(self):

@parameterized.expand([
([], 'no one likes this'),
(['Peter'], 'Peter likes this'),
(['Jacob', 'Alex'], 'Jacob and Alex like this'),
(['Max', 'John', 'Mark'], 'Max, John and Mark like this'),
(['Alex', 'Jacob', 'Mark', 'Max'],
'Alex, Jacob and 2 others like this')])
def test_likes_function(self, names, expected):
"""
Testing likes function with various test data
Testing likes function with various test data.
:return:
"""
# pylint: disable=R0801
Expand All @@ -53,19 +64,9 @@ def test_likes_function(self):
"display text. For 4 or more names, the number in and 2 "
"others simply increases.</p>")
# pylint: enable=R0801
test_data: tuple = (
([], 'no one likes this'),
(['Peter'], 'Peter likes this'),
(['Jacob', 'Alex'], 'Jacob and Alex like this'),
(['Max', 'John', 'Mark'], 'Max, John and Mark like this'),
(['Alex', 'Jacob', 'Mark', 'Max'],
'Alex, Jacob and 2 others like this'))

with allure.step(
"Enter a test data and verify the expected "
"output vs actual result"):

for names, expected in test_data:
actual_result = likes(names)
print_log(exp=expected, res=actual_result)
self.assertEqual(expected, actual_result)
actual_result = likes(names)
print_log(exp=expected, res=actual_result)
self.assertEqual(expected, actual_result)

0 comments on commit cd22053

Please sign in to comment.