Functions WIP

This commit is contained in:
Itai Shirav 2019-07-13 23:01:37 +03:00
parent 8a21e02862
commit cc0f2c4e91
2 changed files with 23 additions and 10 deletions

View File

@ -1136,14 +1136,6 @@ class F(Cond, FunctionOperatorsMixin):
def unhex(x):
return F('unhex', x)
@staticmethod
def UUIDNumToString(s):
return F('UUIDNumToString', s)
@staticmethod
def UUIDStringToNum(s):
return F('UUIDStringToNum', s)
@staticmethod
def bitmaskToArray(x):
return F('bitmaskToArray', x)
@ -1152,7 +1144,23 @@ class F(Cond, FunctionOperatorsMixin):
def bitmaskToList(x):
return F('bitmaskToList', x)
# Functions for working with UUID
@staticmethod
def generateUUIDv4():
return F('generateUUIDv4')
@staticmethod
def toUUID(s):
return F('toUUID', s)
@staticmethod
def UUIDNumToString(s):
return F('UUIDNumToString', s)
@staticmethod
def UUIDStringToNum(s):
return F('UUIDStringToNum', s)

View File

@ -440,9 +440,14 @@ class FuncsTestCase(TestCaseWithData):
self._test_func(F.randConstant(17))
def test_encoding_functions(self):
uuid = '123e4567-e89b-12d3-a456-426655440000'
self._test_func(F.hex(F.unhex('0FA1')), '0FA1')
self._test_func(F.UUIDNumToString(F.UUIDStringToNum(uuid)), uuid)
self._test_func(F.bitmaskToArray(17))
self._test_func(F.bitmaskToList(18))
def test_uuid_functions(self):
from uuid import UUID
uuid = self._test_func(F.generateUUIDv4())
self.assertEqual(type(uuid), UUID)
s = str(uuid)
self._test_func(F.toUUID(s), uuid)
self._test_func(F.UUIDNumToString(F.UUIDStringToNum(s)), s)