示例#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)))