]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/blobdiff - ut/test_db.py
Add tea drinkers ut
[hubacji1/coffee-getter.git] / ut / test_db.py
index 251fc1897dc0854c52052cd81610e348ce8321ed..7f58aa5cb3b81c390cffb440e527e16698b4b7e3 100644 (file)
@@ -26,6 +26,7 @@ ord integer not null default 999
 );
 
 insert or ignore into flavors values
+("tea", 7),
 ("espresso", 2),
 ("espresso lungo", 3),
 ("cappuccino", 1),
@@ -62,6 +63,7 @@ INSERT INTO coffees (id, flavor, time) VALUES
 ('1111', 'espresso lungo', datetime('now', 'localtime', '-95 second')),
 ('1111', 'Club-Mate 0,5 l', datetime('now', 'localtime', '-95 second')),
 ('1111', 'Club-Mate 0,33 l', datetime('now', 'localtime', '-95 second')),
+('1111', 'tea', datetime('now', 'localtime', '-95 second')),
 ('1111', 'espresso lungo', datetime('now', 'localtime', '-90 second')),
 ('1111', 'Club-Mate 0,5 l', datetime('now', 'localtime', '-90 second')),
 ('1111', 'Club-Mate 0,33 l', datetime('now', 'localtime', '-90 second')),
@@ -74,6 +76,8 @@ INSERT INTO coffees (id, flavor, time) VALUES
 ('2222', 'Club-Mate 0,33 l', datetime('now', 'localtime', '-95 second')),
 ('3333', 'espresso lungo', datetime('now', 'localtime', '-99 seconds')),
 ('3333', 'Club-Mate 0,33 l', datetime('now', 'localtime', '-99 seconds')),
+('3333', 'tea', datetime('now', 'localtime', '-99 second')),
+('3333', 'tea', datetime('now', 'localtime', '-95 second')),
 ('3333', 'espresso lungo', datetime('now', 'localtime', '-95 second')),
 ('3333', 'Club-Mate 0,5 l', datetime('now', 'localtime', '-95 second')),
 ('3333', 'Club-Mate 0,33 l', datetime('now', 'localtime', '-95 second'));
@@ -163,6 +167,21 @@ class TopMateDrinkers(TestCase):
             topsorted
         )
 
+class TopTeaDrinkers(TestCase):
+    def setUp(self):
+        create_test_db(TESTDB_FILENAME)
+        self.db = Db(TESTDB_FILENAME)
+
+    def tearDown(self):
+        delete_test_db(TESTDB_FILENAME)
+
+    def test_top_tea_drinkers(self):
+        top = self.db.get_top_tea_drinkers()
+        assert top == [
+            ("clone", 2),
+            ("tester", 1),
+        ]
+
 class DrunkSum(TestCase):
     tdy = datetime.now()
     tdy += timedelta(days=1)