Skip to content

Commit

Permalink
day4
Browse files Browse the repository at this point in the history
  • Loading branch information
Stegallo committed Nov 5, 2023
1 parent e2495f6 commit ff5585c
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions tests/y_2015/test_2015_day4.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
from __future__ import annotations

from unittest.mock import mock_open, patch
from unittest.mock import mock_open, patch, MagicMock

from y_2015.day4 import Day

with patch("builtins.open", mock_open(read_data="")):
day = Day()


def test_calculate_1():
def test_hash_logic():
day._input_data = [["abcdef"]]
day._preprocess_input()
assert day._calculate_1() == 609043
assert day.hash_logic(5) == 609043

day._input_data = [["pqrstuv"]]
day._preprocess_input()
assert day._calculate_1() == 1048970
assert day.hash_logic(5) == 1048970

day._input_data = [["abcdef"]]
day._preprocess_input()
assert day.hash_logic(1) == 31

day._input_data = [["abcdef"]]
day._preprocess_input()
assert day.hash_logic(2) == 298


def test_calculate_1():
day.hash_logic = MagicMock()
day._calculate_1()
day.hash_logic.assert_called_once_with(5)


def test_calculate_2():
day.hash_logic = MagicMock()
day._calculate_2()
day.hash_logic.assert_called_once_with(6)

0 comments on commit ff5585c

Please sign in to comment.