Example #1
0
 def __init__(self, src=None):
     super(MultiTenantSession, self).__init__(src)
     if src:
         fields = src.split('-')
         if len(fields) >= 4:
             if fields[3]:
                 self.owner = long2(fields[3])
             else:
                 self.owner = None
         else:
             raise ValueError("Bad Session: %s" % src)
     else:
         self.owner = None
Example #2
0
 def __init__(self, src=None):
     super(MultiTenantSession, self).__init__(src)
     if src:
         fields = src.split("-")
         if len(fields) >= 4:
             if fields[3]:
                 self.owner = long2(fields[3])
             else:
                 self.owner = None
         else:
             raise ValueError("Bad Session: %s" % src)
     else:
         self.owner = None
Example #3
0
 def test_casts(self):
     p = edm.Property(None)
     p.simpleTypeCode = edm.SimpleType.Byte
     v = edm.SimpleValue.from_property(p)
     v.value = 13
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Int16
     v2 = v.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(
         isinstance(v2, edm.SimpleValue), "cast gives a SimpleValue")
     self.assertTrue(
         v2.type_code == edm.SimpleType.Int16, "cast uses passed type")
     self.assertTrue(v2.value == 13, "cast to Int16")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Int32
     v2 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(
         v2.type_code == edm.SimpleType.Int32, "cast uses passed type")
     self.assertTrue(v2.value == 13, "cast to Int32")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Int64
     v2 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(
         v2.type_code == edm.SimpleType.Int64, "cast uses passed type")
     self.assertTrue(isinstance(v2.value, long2), "cast to Int64")
     self.assertTrue(v2.value == long2(13), "cast to Int64")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Single
     v3 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(
         v3.type_code == edm.SimpleType.Single, "cast uses passed type")
     self.assertTrue(isinstance(v3.value, float), "cast to Single")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Double
     v3 = v3.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(
         v3.type_code == edm.SimpleType.Double, "cast uses passed type")
     self.assertTrue(isinstance(v3.value, float), "cast to Double")
     self.assertTrue(v3.value == 13.0, "cast to Double")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Decimal
     v3 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(
         v3.type_code == edm.SimpleType.Decimal, "cast uses passed type")
     self.assertTrue(
         isinstance(v3.value, decimal.Decimal), "cast to Decimal")
     self.assertTrue(v3 == 13, "cast to Double")
Example #4
0
 def test_casts(self):
     p = edm.Property(None)
     p.simpleTypeCode = edm.SimpleType.Byte
     v = edm.SimpleValue.from_property(p)
     v.value = 13
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Int16
     v2 = v.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(isinstance(v2, edm.SimpleValue),
                     "cast gives a SimpleValue")
     self.assertTrue(v2.type_code == edm.SimpleType.Int16,
                     "cast uses passed type")
     self.assertTrue(v2.value == 13, "cast to Int16")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Int32
     v2 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(v2.type_code == edm.SimpleType.Int32,
                     "cast uses passed type")
     self.assertTrue(v2.value == 13, "cast to Int32")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Int64
     v2 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(v2.type_code == edm.SimpleType.Int64,
                     "cast uses passed type")
     self.assertTrue(isinstance(v2.value, long2), "cast to Int64")
     self.assertTrue(v2.value == long2(13), "cast to Int64")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Single
     v3 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(v3.type_code == edm.SimpleType.Single,
                     "cast uses passed type")
     self.assertTrue(isinstance(v3.value, float), "cast to Single")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Double
     v3 = v3.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(v3.type_code == edm.SimpleType.Double,
                     "cast uses passed type")
     self.assertTrue(isinstance(v3.value, float), "cast to Double")
     self.assertTrue(v3.value == 13.0, "cast to Double")
     cast = edm.Property(None)
     cast.simpleTypeCode = edm.SimpleType.Decimal
     v3 = v2.cast(edm.EDMValue.from_property(cast))
     self.assertTrue(v3.type_code == edm.SimpleType.Decimal,
                     "cast uses passed type")
     self.assertTrue(isinstance(v3.value, decimal.Decimal),
                     "cast to Decimal")
     self.assertTrue(v3 == 13, "cast to Double")
Example #5
0
 def setUp(self):        # noqa
     self.testparams = [uuid.UUID(int=0), 1, long2(2), 3.141, '4',
                        ul("five"), True, False, None]
Example #6
0
 def setUp(self):        # noqa
     self.testparams = [uuid.UUID(int=0), 1, long2(2), 3.141, '4',
                        ul("five"), True, False, None]