aboutsummaryrefslogtreecommitdiff
path: root/backend/tests/test_cal.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-12-29 16:17:39 +1100
committerTerry Truong <terry06890@gmail.com>2022-12-29 16:20:26 +1100
commit20d69469a4c80a196de23625d0420487b0ed04a6 (patch)
treee3a7aad153e72322c0810c66bda3b70daa8d815a /backend/tests/test_cal.py
parent4ad7206443660587a15a7b47384b927188155da8 (diff)
Show event-count data on timeline
Backend: Send event-count data to client in EventResponse instance Fix certain usages of gregorian calendar instead of julian Move HistDate, SCALES, etc, into cal.py Frontend: Make App update a unitCountMaps object using event-count data from server Make TimeLine show visual indication of unit counts Add showEventCounts option to store Update unit tests
Diffstat (limited to 'backend/tests/test_cal.py')
-rw-r--r--backend/tests/test_cal.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/backend/tests/test_cal.py b/backend/tests/test_cal.py
index 7f2aa41..d5f2860 100644
--- a/backend/tests/test_cal.py
+++ b/backend/tests/test_cal.py
@@ -2,7 +2,8 @@ import unittest
from hist_data.cal import \
gregorianToJdn, julianToJdn, jdnToGregorian, jdnToJulian, \
- julianToGregorian, gregorianToJulian
+ julianToGregorian, gregorianToJulian, \
+ MONTH_SCALE, DAY_SCALE, HistDate, dbDateToHistDate, dateToUnit
class TestCal(unittest.TestCase):
def test_gregorian_to_jdn(self):
@@ -27,3 +28,13 @@ class TestCal(unittest.TestCase):
def test_julian_to_gregorian(self):
self.assertEqual(julianToGregorian(2022, 9, 17), (2022, 9, 30))
self.assertEqual(julianToGregorian(1616, 4, 23), (1616, 5, 3))
+ def test_db_to_hist_date(self):
+ self.assertEqual(dbDateToHistDate(2001, 0), HistDate(True, 2001, 1, 1))
+ self.assertEqual(dbDateToHistDate(1721455, 1), HistDate(False, 1, 2, 1))
+ self.assertEqual(dbDateToHistDate(1356438, 2), HistDate(True, -1000, 9, 13))
+ self.assertEqual(dbDateToHistDate(2268942, 3, False), HistDate(False, 1500, 1, 10))
+ self.assertEqual(dbDateToHistDate(2268933, 3, True), HistDate(True, 1500, 1, 10))
+ def test_date_to_unit(self):
+ self.assertEqual(dateToUnit(HistDate(None, 1914, 1, 1), 10), 191)
+ self.assertEqual(dateToUnit(HistDate(True, 1500, 10, 5), MONTH_SCALE), 2269197)
+ self.assertEqual(dateToUnit(HistDate(False, 1500, 1, 10), DAY_SCALE), 2268942)