From b08bf586d653d2243d8bc7a321227f287ce99a74 Mon Sep 17 00:00:00 2001 From: Muriithi Frederick Muriuki Date: Fri, 23 Jul 2021 05:34:59 +0300 Subject: New function (`slink`): return [] on exception Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/computations/slink.py: Add minimum code to pass new test * tests/unit/computations/test_slink.py: new test Add test to ensure that the new `slink` function return an empty list in case and exception is raised. Add the new `slink` function with minimum amount of code needed to pass the test. --- tests/unit/computations/test_slink.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/unit/computations/test_slink.py b/tests/unit/computations/test_slink.py index dd42d5d..bdfaf6d 100644 --- a/tests/unit/computations/test_slink.py +++ b/tests/unit/computations/test_slink.py @@ -2,6 +2,7 @@ import unittest from unittest import TestCase +from gn3.computations.slink import slink from gn3.computations.slink import nearest from gn3.computations.slink import LengthError from gn3.computations.slink import MirrorError @@ -200,3 +201,8 @@ class TestSlink(TestCase): expected_distance=ed): self.assertEqual(nearest(md, ml, mc), ed) self.assertEqual(nearest(md, mc, ml), ed) + + def test_slink_wrong_data_returns_empty_list(self): + for data in [1, "test", [], 2.945, nearest]: + with self.subTest(data=data): + self.assertEqual(slink(data), []) -- cgit v1.2.3