Skip to content
Snippets Groups Projects
Commit 398dcda4 authored by Kien Le's avatar Kien Le
Browse files

Add tests for two_digit_year_to_four_digit_year

parent 8921903c
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !60. Comments created here will be created in the context of that merge request.
import unittest
from sohstationviewer.model.reftek.reftek import (
two_digit_year_to_four_digit_year
)
class TestTwoDigitYearToFourDigitYear(unittest.TestCase):
def test_2000_years(self):
test_cases = {
'0': '2000',
'00': '2000',
'1': '2001',
'01': '2001',
'12': '2012',
'68': '2068',
}
for input, expected_output in test_cases.items():
with self.subTest(f'test_input_{input}'):
result = two_digit_year_to_four_digit_year(input)
self.assertEqual(result, expected_output)
def test_1900_years(self):
test_cases = {
'69': '1969',
'99': '1999',
'75': '1975',
}
for input, expected_output in test_cases.items():
with self.subTest(f'test_input_{input}'):
result = two_digit_year_to_four_digit_year(input)
self.assertEqual(result, expected_output)
def test_invalid_input(self):
with self.subTest('test_negative_year'):
input = '-1'
with self.assertRaises(ValueError):
two_digit_year_to_four_digit_year(input)
with self.subTest('test_year_has_more_than_two_dgit'):
input = '123'
with self.assertRaises(ValueError):
two_digit_year_to_four_digit_year(input)
with self.subTest('test_non_sensical_input'):
input = 'tt'
with self.assertRaises(ValueError):
two_digit_year_to_four_digit_year(input)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment