예제 #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")]
예제 #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", )])
예제 #3
0
 def test_or(self):
     """Expressions cannot be ORed."""
     ce1 = ConstraintExpression("a>1")
     ce2 = ConstraintExpression("b>0")
     with self.assertRaises(ConstraintExpressionError):
         ce1 | ce2
예제 #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")
예제 #5
0
 def test_unicode(self):
     """Test unicode representation."""
     ce = ConstraintExpression("a>1")
     self.assertEqual(text_type(ce), "a>1")
예제 #6
0
 def test_str(self):
     """Test string representation."""
     ce = ConstraintExpression("a>1")
     self.assertEqual(str(ce), "a>1")
예제 #7
0
파일: dap.py 프로젝트: lukecampbell/pydap
 def __lt__(self, other):
     return ConstraintExpression('%s<%s' % (self.id, encode(other)))