Skip to content

Commit

Permalink
# Computer problem series #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent b9059f9 commit 9f0be14
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 41 deletions.
1 change: 1 addition & 0 deletions kyu_7/fill_the_hard_disk_drive/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Computer problem series #1."""
11 changes: 7 additions & 4 deletions kyu_7/fill_the_hard_disk_drive/save.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Computer problem series #1: Fill the Hard Disk Drive
Solution for -> Computer problem series #1: Fill the Hard Disk Drive.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def save(sizes: list, hd: int) -> int:
"""
'Save' function.
Your task is to determine how many files of the
copy queue you will be able to save into your
Hard Disk Drive.
Expand All @@ -18,9 +21,9 @@ def save(sizes: list, hd: int) -> int:
Output:
Number of files that can be fully saved in the HD
:param sizes:
:param hd:
:return:
:param sizes: list
:param hd: int
:return: int
"""
counter: int = 0
total: int = 0
Expand Down
65 changes: 28 additions & 37 deletions kyu_7/fill_the_hard_disk_drive/test_save.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Computer problem series #1: Fill the Hard Disk Drive
Test for -> Computer problem series #1: Fill the Hard Disk Drive.
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_7.fill_the_hard_disk_drive.save import save

Expand All @@ -29,13 +31,14 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class SaveTestCase(unittest.TestCase):
"""
Testing 'save' function
"""
"""Testing 'save' function."""

def test_save_negative(self):
@parameterized.expand([
([11, 13, 15, 17, 19], 8, 0),
([45], 12, 0)])
def test_save_negative(self, sizes, hd, expected):
"""
Testing 'save' function: negative
Testing 'save' function: negative.
The function should determine how many
files of the copy queue you will be able
Expand All @@ -52,22 +55,22 @@ def test_save_negative(self):
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter sizes, hd and verify the output"):
data: tuple = (
([11, 13, 15, 17, 19], 8, 0),
([45], 12, 0))

for sizes, hd, expected in data:
print_log(sizes=sizes,
hd=hd,
expected=expected)

self.assertEqual(expected,
save(sizes, hd))
with allure.step(f"Enter sizes: {sizes}, "
f"hd: {hd} "
f"and verify the expected output: {expected}."):
print_log(sizes=sizes, hd=hd, expected=expected)
self.assertEqual(expected, save(sizes, hd))

def test_save_positive(self):
@parameterized.expand([
([4, 4, 4, 3, 3], 12, 3),
([4, 4, 4, 3, 3], 11, 2),
([4, 8, 15, 16, 23, 42], 108, 6),
([13], 13, 1),
([1, 2, 3, 4], 250, 4),
([100], 500, 1)])
def test_save_positive(self, sizes, hd, expected):
"""
Testing 'save' function: positive
Testing 'save' function: positive.
The function should determine how many
files of the copy queue you will be able
Expand All @@ -84,20 +87,8 @@ def test_save_positive(self):
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter sizes, hd and verify the output"):
data: tuple = (
([4, 4, 4, 3, 3], 12, 3),
([4, 4, 4, 3, 3], 11, 2),
([4, 8, 15, 16, 23, 42], 108, 6),
([13], 13, 1),
([1, 2, 3, 4], 250, 4),
([100], 500, 1))

for sizes, hd, expected in data:

print_log(sizes=sizes,
hd=hd,
expected=expected)

self.assertEqual(expected,
save(sizes, hd))
with allure.step(f"Enter sizes: {sizes}, "
f"hd: {hd} "
f"and verify the expected output: {expected}."):
print_log(sizes=sizes, hd=hd, expected=expected)
self.assertEqual(expected, save(sizes, hd))

0 comments on commit 9f0be14

Please sign in to comment.