def test_keep_if_more_other(self): """keep_if_more_other should be True if #other items > x""" self.assertRaises(ValueError, keep_if_more_other,'lksfj','ks') #not int self.assertRaises(IndexError,keep_if_more_other,'ACGU',-3) #negative f = keep_if_more_other('a',0) #zero self.assertEqual(f(''),0) self.assertEqual(f('a'),0) self.assertEqual(f('b'),1) # works on strings f = keep_if_more_other('ACGU',5) #positive self.assertEqual(f(''),0) self.assertEqual(f('ACGUNNNNN'),0) self.assertEqual(f('ACGUAGCUioooNNNNNA'),1) self.assertEqual(f('NNNNNNN'),1) # works on words f = keep_if_more_other(['foo'],1) self.assertEqual(f(''),0) self.assertEqual(f(['foo', 'bar','foo']),0) self.assertEqual(f(['joe','oef']),1) # works on numbers f = keep_if_more_other([0,1],3) self.assertEqual(f(''),0) self.assertEqual(f([0,1,2,3,4,5]),1) self.assertEqual(f([0,1,0,1]),0)
def test_keep_if_more_other(self): """keep_if_more_other should be True if #other items > x""" self.assertRaises(ValueError, keep_if_more_other, 'lksfj', 'ks') #not int self.assertRaises(IndexError, keep_if_more_other, 'ACGU', -3) #negative f = keep_if_more_other('a', 0) #zero self.assertEqual(f(''), 0) self.assertEqual(f('a'), 0) self.assertEqual(f('b'), 1) # works on strings f = keep_if_more_other('ACGU', 5) #positive self.assertEqual(f(''), 0) self.assertEqual(f('ACGUNNNNN'), 0) self.assertEqual(f('ACGUAGCUioooNNNNNA'), 1) self.assertEqual(f('NNNNNNN'), 1) # works on words f = keep_if_more_other(['foo'], 1) self.assertEqual(f(''), 0) self.assertEqual(f(['foo', 'bar', 'foo']), 0) self.assertEqual(f(['joe', 'oef']), 1) # works on numbers f = keep_if_more_other([0, 1], 3) self.assertEqual(f(''), 0) self.assertEqual(f([0, 1, 2, 3, 4, 5]), 1) self.assertEqual(f([0, 1, 0, 1]), 0)
def test_keep_if_more_other(self): """keep_if_more_other should be True if #other items > x""" self.assertRaises(ValueError, keep_if_more_other, "lksfj", "ks") # not int self.assertRaises(IndexError, keep_if_more_other, "ACGU", -3) # negative f = keep_if_more_other("a", 0) # zero self.assertEqual(f(""), 0) self.assertEqual(f("a"), 0) self.assertEqual(f("b"), 1) # works on strings f = keep_if_more_other("ACGU", 5) # positive self.assertEqual(f(""), 0) self.assertEqual(f("ACGUNNNNN"), 0) self.assertEqual(f("ACGUAGCUioooNNNNNA"), 1) self.assertEqual(f("NNNNNNN"), 1) # works on words f = keep_if_more_other(["foo"], 1) self.assertEqual(f(""), 0) self.assertEqual(f(["foo", "bar", "foo"]), 0) self.assertEqual(f(["joe", "oef"]), 1) # works on numbers f = keep_if_more_other([0, 1], 3) self.assertEqual(f(""), 0) self.assertEqual(f([0, 1, 2, 3, 4, 5]), 1) self.assertEqual(f([0, 1, 0, 1]), 0)
def test_init(self): """Filter should init as expected""" empty_filter = Filter('',{}) named_empty_filter = Filter('Archaea',{}) self.assertEqual(empty_filter,{}) self.assertEqual(empty_filter.Name,'') self.assertEqual(named_empty_filter,{}) self.assertEqual(named_empty_filter.Name,'Archaea') f = find_all('abcd') g = keep_if_more_other('ab',7) fil = Filter('Archaea',{'Arch':[f,g]}) assert fil['Arch'][0] is f assert fil['Arch'][1] is g
def test_init(self): """Filter should init as expected""" empty_filter = Filter('', {}) named_empty_filter = Filter('Archaea', {}) self.assertEqual(empty_filter, {}) self.assertEqual(empty_filter.Name, '') self.assertEqual(named_empty_filter, {}) self.assertEqual(named_empty_filter.Name, 'Archaea') f = find_all('abcd') g = keep_if_more_other('ab', 7) fil = Filter('Archaea', {'Arch': [f, g]}) assert fil['Arch'][0] is f assert fil['Arch'][1] is g