mirror of https://github.com/eyhc1/rendercv.git
fix date bugs
This commit is contained in:
parent
0e28c5062e
commit
45274eb8b6
|
@ -69,15 +69,15 @@ class TestRendercv(unittest.TestCase):
|
||||||
# Inputs with valid dates:
|
# Inputs with valid dates:
|
||||||
inputs = [
|
inputs = [
|
||||||
{
|
{
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2021, month=1, day=1),
|
"end_date": "2021-01-01",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": None,
|
"end_date": None,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": "present",
|
"end_date": "present",
|
||||||
},
|
},
|
||||||
{"date": "My Birthday"},
|
{"date": "My Birthday"},
|
||||||
|
@ -93,16 +93,16 @@ class TestRendercv(unittest.TestCase):
|
||||||
|
|
||||||
# Inputs with invalid dates:
|
# Inputs with invalid dates:
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2019, month=1, day=1),
|
"end_date": "2019-01-01",
|
||||||
}
|
}
|
||||||
with self.subTest(msg="start_date > end_date"):
|
with self.subTest(msg="start_date > end_date"):
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
data_model.Event(**input)
|
data_model.Event(**input)
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2900, month=1, day=1),
|
"end_date": "2900-01-01",
|
||||||
}
|
}
|
||||||
with self.subTest(msg="end_date > present"):
|
with self.subTest(msg="end_date > present"):
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
|
@ -110,18 +110,18 @@ class TestRendercv(unittest.TestCase):
|
||||||
|
|
||||||
# Other inputs:
|
# Other inputs:
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": "present",
|
"end_date": "present",
|
||||||
"date": "My Birthday",
|
"date": "My Birthday",
|
||||||
}
|
}
|
||||||
event = data_model.Event(**input)
|
event = data_model.Event(**input)
|
||||||
with self.subTest(msg="start_date, end_date, and date are all provided"):
|
with self.subTest(msg="start_date, end_date, and date are all provided"):
|
||||||
self.assertEqual(event.date, None)
|
self.assertEqual(event.date, None)
|
||||||
self.assertEqual(event.start_date, input["start_date"])
|
self.assertEqual(event.start_date, Date.fromisoformat(input["start_date"]))
|
||||||
self.assertEqual(event.end_date, input["end_date"])
|
self.assertEqual(event.end_date, input["end_date"])
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": None,
|
"end_date": None,
|
||||||
"date": "My Birthday",
|
"date": "My Birthday",
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ class TestRendercv(unittest.TestCase):
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"start_date": None,
|
"start_date": None,
|
||||||
"end_date": Date(year=2020, month=1, day=1),
|
"end_date": "2020-01-01",
|
||||||
"date": "My Birthday",
|
"date": "My Birthday",
|
||||||
}
|
}
|
||||||
event = data_model.Event(**input)
|
event = data_model.Event(**input)
|
||||||
|
@ -145,18 +145,18 @@ class TestRendercv(unittest.TestCase):
|
||||||
input = {
|
input = {
|
||||||
"start_date": None,
|
"start_date": None,
|
||||||
"end_date": None,
|
"end_date": None,
|
||||||
"date": "My Birthday",
|
"date": "2020-01-01",
|
||||||
}
|
}
|
||||||
event = data_model.Event(**input)
|
event = data_model.Event(**input)
|
||||||
with self.subTest(msg="only date is provided"):
|
with self.subTest(msg="only date is provided"):
|
||||||
self.assertEqual(event.start_date, None)
|
self.assertEqual(event.start_date, None)
|
||||||
self.assertEqual(event.end_date, None)
|
self.assertEqual(event.end_date, None)
|
||||||
self.assertEqual(event.date, input["date"])
|
self.assertEqual(event.date, Date.fromisoformat(input["date"]))
|
||||||
|
|
||||||
def test_data_event_date_and_location_strings_with_timespan(self):
|
def test_data_event_date_and_location_strings_with_timespan(self):
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2021, month=1, day=16),
|
"end_date": "2021-01-16",
|
||||||
"location": "My Location",
|
"location": "My Location",
|
||||||
}
|
}
|
||||||
expected = [
|
expected = [
|
||||||
|
@ -183,7 +183,7 @@ class TestRendercv(unittest.TestCase):
|
||||||
self.assertEqual(result, expected)
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"date": Date(year=2020, month=1, day=1),
|
"date": "2020-01-01",
|
||||||
}
|
}
|
||||||
expected = [
|
expected = [
|
||||||
"Jan. 2020",
|
"Jan. 2020",
|
||||||
|
@ -194,8 +194,8 @@ class TestRendercv(unittest.TestCase):
|
||||||
self.assertEqual(result, expected)
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2021, month=1, day=16),
|
"end_date": "2021-01-16",
|
||||||
}
|
}
|
||||||
expected = [
|
expected = [
|
||||||
"Jan. 2020 to Jan. 2021",
|
"Jan. 2020 to Jan. 2021",
|
||||||
|
@ -219,8 +219,8 @@ class TestRendercv(unittest.TestCase):
|
||||||
|
|
||||||
def test_data_event_date_and_location_strings_without_timespan(self):
|
def test_data_event_date_and_location_strings_without_timespan(self):
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2021, month=1, day=16),
|
"end_date": "2021-01-16",
|
||||||
"location": "My Location",
|
"location": "My Location",
|
||||||
}
|
}
|
||||||
expected = [
|
expected = [
|
||||||
|
@ -311,8 +311,8 @@ class TestRendercv(unittest.TestCase):
|
||||||
|
|
||||||
def test_data_event_month_and_year(self):
|
def test_data_event_month_and_year(self):
|
||||||
input = {
|
input = {
|
||||||
"start_date": Date(year=2020, month=1, day=1),
|
"start_date": "2020-01-01",
|
||||||
"end_date": Date(year=2021, month=1, day=16),
|
"end_date": "2021-01-16",
|
||||||
}
|
}
|
||||||
expected = None
|
expected = None
|
||||||
event = data_model.Event(**input)
|
event = data_model.Event(**input)
|
||||||
|
@ -330,7 +330,7 @@ class TestRendercv(unittest.TestCase):
|
||||||
self.assertEqual(result, expected)
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"date": Date(year=2020, month=1, day=1),
|
"date": "2020-01-01",
|
||||||
}
|
}
|
||||||
expected = "Jan. 2020"
|
expected = "Jan. 2020"
|
||||||
event = data_model.Event(**input)
|
event = data_model.Event(**input)
|
||||||
|
@ -439,6 +439,17 @@ class TestRendercv(unittest.TestCase):
|
||||||
with self.subTest(msg="gpa, transcript_url, and highlights are provided"):
|
with self.subTest(msg="gpa, transcript_url, and highlights are provided"):
|
||||||
self.assertEqual(result, expected)
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
|
def test_data_publication_netry_doi_url(self):
|
||||||
|
input = {
|
||||||
|
"title": "My Publication",
|
||||||
|
"authors": [
|
||||||
|
"Author 1",
|
||||||
|
"Author 2",
|
||||||
|
],
|
||||||
|
"doi": "invalidDoi",
|
||||||
|
"date": "2020-01-01",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue