Skip to content

Commit

Permalink
# Vasya - Clerk
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 18, 2024
1 parent 62d1e18 commit 168a6b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.
1 change: 1 addition & 0 deletions kyu_6/vasya_clerk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Vasya - Clerk."""
54 changes: 23 additions & 31 deletions kyu_6/vasya_clerk/test_tickets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Vasya - Clerk
Test for -> Vasya - Clerk.
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.vasya_clerk.tickets import tickets

Expand All @@ -27,10 +29,24 @@
url='https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8',
name='Source/Kata')
class TicketsTestCase(unittest.TestCase):
"""
Testing tickets function
"""
def test_tickets(self):
"""Testing tickets function."""

@parameterized.expand([
([25, 25, 50], 'YES', 'All good'),
([25, 100], 'NO',
'Vasya will not have enough money '

Check warning on line 37 in kyu_6/vasya_clerk/test_tickets.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

kyu_6/vasya_clerk/test_tickets.py#L37

Detected strings that are implicitly concatenated inside a list.
'to give change to 100 dollars'),
([25, 25, 50, 50, 100], 'NO',
'Vasya will not have the right bills '

Check warning on line 40 in kyu_6/vasya_clerk/test_tickets.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

kyu_6/vasya_clerk/test_tickets.py#L40

Detected strings that are implicitly concatenated inside a list.
'to give 75 dollars of change (you can\'t '
'make two bills of 25 from one of 50)'),
([25, 50, 25, 100, 25, 25, 50, 100, 25, 25, 25,
100, 25, 25, 50, 100, 25, 50, 25, 100, 25, 50,
50, 50], 'NO', 'N/A'),
([25, 25, 25, 100, 25, 25, 25, 100, 25,
25, 50, 100, 25, 25, 50, 100, 50, 50],
'NO', 'N/A')])
def test_tickets(self, arr, expected, msg):
"""
Testing tickets function with various test inputs.
Expand Down Expand Up @@ -64,29 +80,5 @@ def test_tickets(self):
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter test input (list) and verify the output"):
test_data: tuple = (
([25, 25, 50],
'YES',
'All good'),
([25, 100],
'NO',
'Vasya will not have enough money '
'to give change to 100 dollars'),
([25, 25, 50, 50, 100],
'NO',
'Vasya will not have the right bills '
'to give 75 dollars of change (you can\'t '
'make two bills of 25 from one of 50)'),
([25, 50, 25, 100, 25, 25, 50, 100, 25, 25, 25,
100, 25, 25, 50, 100, 25, 50, 25, 100, 25, 50,
50, 50],
'NO',
'N/A'),
([25, 25, 25, 100, 25, 25, 25, 100, 25,
25, 50, 100, 25, 25, 50, 100, 50, 50],
'NO',
'N/A'))

for arr, expected, msg in test_data:
print_log(people=arr, expected=expected, msg=msg)
self.assertEqual(expected, tickets(arr), msg)
print_log(people=arr, expected=expected, msg=msg)
self.assertEqual(expected, tickets(arr), msg)
5 changes: 4 additions & 1 deletion kyu_6/vasya_clerk/tickets.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Vasya - Clerk
Solution for -> Vasya - Clerk.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def tickets(people: list) -> str:
"""
Tickets.
Return YES, if Vasya can sell a ticket to every
person and give change with the bills he has at
hand at that moment. Otherwise return NO.
Expand Down

0 comments on commit 168a6b0

Please sign in to comment.