Esempio n. 1
0
    def test_invalid_selection(self):
        """Test invalid selections.

        In theory this should never happen, since ``ConstraintExpression``
        object are constructly directly from existing children.

        """
        with self.assertRaises(ConstraintExpressionError):
            self.data[ConstraintExpression("a.e<1")]
        with self.assertRaises(ConstraintExpressionError):
            self.data[ConstraintExpression("a.d<foo")]
Esempio n. 2
0
    def test_regexp(self):
        sequence = SequenceType("sequence")
        sequence["name"] = BaseType("name")
        sequence.data = IterData([
            ("John", "Paul", "George", "Ringo"),
        ], sequence)

        filtered = sequence[ConstraintExpression('sequence.name=~"J.*"')]
        self.assertEqual(list(filtered.iterdata()), [("John", )])
Esempio n. 3
0
 def test_or(self):
     """Expressions cannot be ORed."""
     ce1 = ConstraintExpression("a>1")
     ce2 = ConstraintExpression("b>0")
     with self.assertRaises(ConstraintExpressionError):
         ce1 | ce2
Esempio n. 4
0
 def test_and(self):
     """Test CE addition."""
     ce1 = ConstraintExpression("a>1")
     ce2 = ConstraintExpression("b>0")
     ce3 = ce1 & ce2
     self.assertEqual(str(ce3), "a>1&b>0")
Esempio n. 5
0
 def test_unicode(self):
     """Test unicode representation."""
     ce = ConstraintExpression("a>1")
     self.assertEqual(text_type(ce), "a>1")
Esempio n. 6
0
 def test_str(self):
     """Test string representation."""
     ce = ConstraintExpression("a>1")
     self.assertEqual(str(ce), "a>1")
Esempio n. 7
0
 def __lt__(self, other):
     return ConstraintExpression('%s<%s' % (self.id, encode(other)))