示例#1
0
 def test_removeOption_noneLeft(self):
     """removeOption should cull options and return F when none left."""
     
     test = SearchNode(SearchNodeHelper.alphabet)
     num_options = len(test.Options)
     
     #removeOption num_options times: that should get 'em all
     for i in xrange(num_options): some_left = test.removeOption()
     
     #return value should be false (no options remain)
     self.assertEqual(some_left, False)        
示例#2
0
 def test_removeOption_someLeft(self):
     """removeOption should cull options and return T when some left."""
     
     #create a search node and get its current value
     test = SearchNode(SearchNodeHelper.alphabet)
     last_val = test.Value
     
     some_left = test.removeOption()
     
     #new current value must be different from old
     #and return value must be true
     self.assertNotEqual(test.Value, last_val)
     self.assertEqual(some_left, True)
示例#3
0
    def test_check_forbidden_seqs_none(self):
        """Should return False if path includes no forbidden seqs"""
        
        #a seq that isn't in the standard fixed forbidden lib
        allowed_seq = ["C", "U", "A", "T"]        
        
        test = SearchPath(SearchPathHelper.alphabets, \
                SearchPathHelper.standard_forbid_seq)
        test._add_node(SearchNode(SearchNodeHelper.alphabet))

        #add more values, and cheat so as to make them something known
        for known_val in allowed_seq:
            curr_node = SearchNode(SearchNodeHelper.alphabet)
            curr_node._options[0] = known_val #torque the node's innards
            test._add_node(curr_node)
        #next bad_val
        
        real_result = test._check_forbidden_seqs()
        self.assertEquals(real_result, False)            
示例#4
0
 def test_check_forbidden_seqs_fixed(self):
     """Should return True if path includes a fixed forbidden seq"""
     
     forbidden_seq = ["G", "U", "A"]     
     user_input = ["".join(forbidden_seq)]
     user_input.extend(SearchPathHelper.standard_forbid_seq)
     
     test = SearchPath(SearchPathHelper.alphabets, user_input)
     test._add_node(SearchNode(SearchNodeHelper.alphabet))
     
     #add more values, and cheat so as to make them something forbidden
     for bad_val in forbidden_seq:
         curr_node = SearchNode(SearchNodeHelper.alphabet)
         curr_node._options[0] = bad_val #torque the node's innards
         test._add_node(curr_node)
     #next bad_val
     
     real_result = test._check_forbidden_seqs()
     self.assertEquals(real_result, True)