<s> from __future__ import unicode_literals <EOL> from nose . plugins . attrib import attr <EOL> from tornado . testing import gen_test <EOL> from . base_tests import GraphPropertyBaseClassTestCase <EOL> from goblin . _compat import PY2 <EOL> from goblin . properties . properties import UUID <EOL> from goblin . properties . base import GraphProperty , ValidationError <EOL> from goblin . models import Vertex <EOL> from goblin . _compat import print_ <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class UUID4PropertyTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> klass = UUID <EOL> good_cases = ( '<STR_LIT>' , None ) <EOL> if PY2 : <EOL> bad_cases = ( '<STR_LIT>' , [ ] , ( ) , { } , <NUM_LIT:0> , long ( <NUM_LIT:1> ) , False , <NUM_LIT> ) <EOL> else : <EOL> bad_cases = ( '<STR_LIT>' , [ ] , ( ) , { } , <NUM_LIT:0> , False , <NUM_LIT> ) <EOL> def test_to_database_method ( self ) : <EOL> u = self . klass ( default = None ) <EOL> self . assertIsNone ( u . to_database ( None ) ) <EOL> class UUID4TestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val = UUID ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class UUID4VertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_uuid4_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> dt = yield UUID4TestVertex . create ( <EOL> test_val = '<STR_LIT>' ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield UUID4TestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , dt . test_val ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> dt = yield UUID4TestVertex . create ( <EOL> test_val = '<STR_LIT>' ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield UUID4TestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , '<STR_LIT>' ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class UUID1PropertyTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> klass = UUID ( ) <EOL> good_cases = ( '<STR_LIT>' , None ) <EOL> if PY2 : <EOL> bad_cases = ( '<STR_LIT>' , [ ] , ( ) , { } , <NUM_LIT:0> , long ( <NUM_LIT:1> ) , False , <NUM_LIT> ) <EOL> else : <EOL> bad_cases = ( '<STR_LIT>' , [ ] , ( ) , { } , <NUM_LIT:0> , False , <NUM_LIT> ) <EOL> def test_subclass ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertIsSubclass ( self . klass . __class__ , GraphProperty ) <EOL> def test_validation ( self ) : <EOL> for case in self . good_cases : <EOL> print_ ( "<STR_LIT>" % ( case , ) ) <EOL> self . assertNotRaise ( self . klass . validate , case ) <EOL> for case in self . bad_cases : <EOL> print_ ( "<STR_LIT>" % ( case , ) ) <EOL> self . assertRaises ( ValidationError , self . klass . validate , case ) <EOL> class UUID1TestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val = UUID ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class UUID1VertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_uuid1_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> dt = yield UUID1TestVertex . create ( <EOL> test_val = '<STR_LIT>' ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield UUID1TestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , dt . test_val ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> dt = yield UUID1TestVertex . create ( <EOL> test_val = '<STR_LIT>' ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield UUID1TestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , '<STR_LIT>' ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) </s>
