From 995c5623002ed4e6e75c5fddab439dc8577a2a06 Mon Sep 17 00:00:00 2001 From: Masanari Kimura Date: Sat, 2 Jan 2021 17:56:32 +0900 Subject: [PATCH] add test case --- tests/test_recall.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_recall.py b/tests/test_recall.py index 31b2514..8a0c4db 100644 --- a/tests/test_recall.py +++ b/tests/test_recall.py @@ -15,6 +15,28 @@ def test_recall_inherited_BaseTimeSeriesMetrics(self): isinstance(recall, BaseTimeSeriesMetrics) ) + def test_RecallClass_init(self): + """ Test of init function. + """ + + test_case_1 = {'alpha': 0.0, 'cardinality': 'one', 'bias': 'flat'} + test_case_2 = {'alpha': 0.0, 'cardinality': 'one', 'bias': None} + test_case_3 = {'alpha': 10.0, 'cardinality': 'one', 'bias': 'flat'} + + # test of the normal call + obj = TimeSeriesRecall(**test_case_1) + self.assertEqual(obj.alpha, test_case_1['alpha']) + self.assertEqual(obj.cardinality, test_case_1['cardinality']) + self.assertEqual(obj.bias, test_case_1['bias']) + + # test of the invalid bias + with self.assertRaises(Exception): + obj = TimeSeriesRecall(**test_case_2) + + # test of the invalid alpha + with self.assertRaises(Exception): + obj = TimeSeriesRecall(**test_case_3) + def test_recall_function(self): """Teest of ts_recall function. """