-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from Stegallo/2022-bis
test day1
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from __future__ import annotations | ||
|
||
from unittest.mock import mock_open, patch | ||
|
||
from y_2022.day1 import Day | ||
|
||
with patch("builtins.open", mock_open(read_data="0")): | ||
day = Day() | ||
|
||
|
||
def test__preprocess_input(): | ||
day._input_data = [] | ||
day._preprocess_input() | ||
assert day._Day__input_data == [] | ||
|
||
day._input_data = [ | ||
["1000", "2000", "3000"], | ||
["4000"], | ||
["5000", "6000"], | ||
["7000", "8000", "9000"], | ||
["10000"], | ||
] | ||
day._preprocess_input() | ||
assert day._Day__input_data == [ | ||
[1000, 2000, 3000], | ||
[4000], | ||
[5000, 6000], | ||
[7000, 8000, 9000], | ||
[10000], | ||
] | ||
|
||
|
||
def test_calculate_1(): | ||
day._Day__input_data = [ | ||
[1000, 2000, 3000], | ||
[4000], | ||
] | ||
assert day._calculate_1() == 6000 | ||
|
||
|
||
def test_calculate_2(): | ||
day._Day__input_data = [ | ||
[1000, 2000, 3000], | ||
[4000], | ||
[5000, 6000], | ||
[7000, 8000, 9000], | ||
] | ||
assert day._calculate_2() == 41000 |