def test_contains_set_primitive(self): self.assertTrue({1, 2, 3} in Set[Int]) self.assertTrue({-1, 2, 3} in Set[Int]) self.assertFalse({-1, 2, 3} in Set[Int % Range(0, 5)]) self.assertFalse({1, 1.1, 1.11} in Set[Int]) self.assertFalse([1, 2, 3] in Set[Int]) self.assertFalse(object() in Set[Int])
def test_from_function_with_parameters_only(self): visualizer = self.plugin.visualizers['params_only_viz'] self.assertEqual(visualizer.id, 'params_only_viz') exp_sig = VisualizerSignature(params_only_viz, inputs={}, parameters={ 'name': qiime2.plugin.Str, 'age': qiime2.plugin.Int % Range(0, None) }) self.assertEqual(visualizer.signature, exp_sig) self.assertEqual(visualizer.name, 'Parameters only viz') self.assertTrue( visualizer.description.startswith('This visualizer only accepts ' 'parameters.')) self.assertTrue( visualizer.source.startswith('\n```python\ndef params_only_viz('))
def test_no_predicate(self): with self.assertRaisesRegex(TypeError, 'no predicate'): List[Int] % Range(5)
def test_set_primitive_type(self): self.assertTrue(is_collection_type(Set[Int % Range(5)])) self.assertTrue(is_primitive_type(Set[Int % Range(5)])) self.assertFalse(is_semantic_type(Set[Int % Range(5)]))
def test_to_ast_primitive(self): ast = List[Int % Range(5)].to_ast() self.assertEqual(ast['fields'][0], (Int % Range(5)).to_ast()) self.assertEqual(ast['type'], 'collection')
def test_no_predicate(self): with self.assertRaisesRegex(TypeError, 'cannot be applied'): List[Int] % Range(5)