diff --git a/kyu_6/potion_class_101/__init__.py b/kyu_6/potion_class_101/__init__.py index e69de29bb2d..d8a2cfb8484 100644 --- a/kyu_6/potion_class_101/__init__.py +++ b/kyu_6/potion_class_101/__init__.py @@ -0,0 +1 @@ +"""Potion Class 101.""" diff --git a/kyu_6/potion_class_101/potion.py b/kyu_6/potion_class_101/potion.py index 77dab6da517..11105cfe3ff 100644 --- a/kyu_6/potion_class_101/potion.py +++ b/kyu_6/potion_class_101/potion.py @@ -1,5 +1,6 @@ """ -Solution for -> Potion Class 101 +Solution for -> Potion Class 101. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -11,22 +12,32 @@ class Potion: """ + Potion. + This is your first potion class in Hogwarts and professor gave you a homework to figure out what color potion will turn into if he'll mix it with some other potion. All potions have some color that written down as RGB color from [0, 0, 0] to [255, 255, 255]. To make task more complicated teacher will do few mixing and after will ask you for final color. Besides - color you also need to figure out what volume will have potion + color, you also need to figure out what volume will have potion after final mix. """ def __init__(self, color: Tuple[int, int, int], volume: int): + """ + Create a new Potion instance. + + :param color: + :param volume: + """ self._color: Tuple[int, int, int] = color self._volume: int = volume def mix(self, other) -> object: """ + Mix. + Based on your programming background you managed to figure that after mixing two potions colors will mix as if mix two RGB colors. @@ -49,7 +60,8 @@ def mix(self, other) -> object: @property def volume(self) -> int: """ - Return volume value + Return volume value. + :return: int """ return self._volume @@ -57,7 +69,8 @@ def volume(self) -> int: @volume.setter def volume(self, value: int) -> None: """ - Set volume value + Set volume value. + :param value: int :return: """ @@ -66,7 +79,8 @@ def volume(self, value: int) -> None: @property def color(self) -> tuple: """ - Get color value + Get color value. + :return: tuple """ return self._color @@ -74,7 +88,8 @@ def color(self) -> tuple: @color.setter def color(self, value: Tuple[int, int, int]) -> None: """ - Set color value + Set color value. + :param value: tuple :return: """ diff --git a/kyu_6/potion_class_101/test_potion.py b/kyu_6/potion_class_101/test_potion.py index c964e3992b8..3159c596afa 100644 --- a/kyu_6/potion_class_101/test_potion.py +++ b/kyu_6/potion_class_101/test_potion.py @@ -1,5 +1,6 @@ """ -Test for -> Potion Class 101 +Test for -> Potion Class 101. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from utils.log_func import print_log from kyu_6.potion_class_101.potion import Potion @@ -22,12 +24,12 @@ url='https://www.codewars.com/kata/5981ff1daf72e8747d000091', name='Source/Kata') class PotionTestCase(unittest.TestCase): - """ - Testing potion func for Potion Class 101 problem - """ + """Testing potion func for Potion Class 101 problem.""" + def test_potion(self): """ - Testing potion function with various test inputs + Testing potion function with various test inputs. + :return: """ # pylint: disable-msg=R0801 @@ -56,19 +58,32 @@ def test_potion(self): e = potions[0].mix(potions[1]).mix(potions[2]).mix( potions[3]).mix(potions[4]).mix(potions[5]) - with allure.step("Mix between RGB colors and verify the output"): - + with allure.step(f"Mix between RGB colors: {(147, 149, 130)} " + f"and verify the output: {a.color, a.volume}."): self.assertEqual((147, 149, 130), a.color) self.assertEqual(49, a.volume) + print_log(expected=49, result=a.volume) + with allure.step(f"Mix between RGB colors: {(135, 101, 128)} " + f"and verify the output: {b.color, b.volume}."): self.assertEqual((135, 101, 128), b.color) self.assertEqual(76, b.volume) + print_log(expected=76, result=b.volume) + with allure.step(f"Mix between RGB colors: {(74, 50, 18)} " + f"and verify the output: {c.color, c.volume}."): self.assertEqual((74, 50, 18), c.color) self.assertEqual(52, c.volume) + print_log(expected=52, result=c.volume) + with allure.step(f"Mix between RGB colors: {(130, 91, 102)} " + f"and verify the output: {d.color, d.volume}."): self.assertEqual((130, 91, 102), d.color) self.assertEqual(99, d.volume) + print_log(expected=99, result=d.volume) + with allure.step(f"Mix between RGB colors: {(132, 96, 99)} " + f"and verify the output: {e.color, e.volume}."): self.assertEqual((132, 96, 99), e.color) self.assertEqual(103, e.volume) + print_log(expected=103, result=e.volume)