def test_k_nearest(self): results, code = k_nearest(dataset='dataset1', beta_metric='unifrac', k=1, sample_id='s1') self.assertCountEqual(json.loads(results), ['s2']) results, code = k_nearest(dataset='dataset1', beta_metric='unifrac', k=2, sample_id='s2') self.assertCountEqual(json.loads(results), ['s1', 's3'])
def test_k_nearest_invalid_k(self): with self.assertRaises(InvalidParameter): k_nearest(dataset='dataset1', beta_metric='unifrac', k=724, sample_id='s2')
def test_k_nearest_unknown_id(self): with self.assertRaises(UnknownID): k_nearest(dataset='dataset1', beta_metric='unifrac', k=2, sample_id='s2-dne')
def test_k_nearest_unknown_metric(self): with self.assertRaises(UnknownMetric): k_nearest(dataset='dataset1', beta_metric='unifork', k=2, sample_id='s2')
def test_k_nearest_unknown_dataset(self): with self.assertRaises(UnknownResource): k_nearest(dataset='dne', beta_metric='unifrac', k=2, sample_id='s2')