<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 , create_key <EOL> from goblin import connection <EOL> from goblin . properties . properties import Integer , Short , PositiveInteger , Long , PositiveLong <EOL> from goblin . models import Vertex <EOL> from goblin . _compat import print_ , long_ <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class IntegerPropertyTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> klass = Integer <EOL> good_cases = ( <NUM_LIT:1> , <NUM_LIT:0> , None ) <EOL> bad_cases = ( '<STR_LIT>' , '<STR_LIT:a>' , <NUM_LIT> , [ ] , [ <NUM_LIT:1> ] , { } , { '<STR_LIT:a>' : <NUM_LIT:1> } ) <EOL> @ gen_test <EOL> def test_manual_schema ( self ) : <EOL> key = IntegerTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> label = IntegerTestVertex . get_label ( ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> stream = yield connection . execute_query ( <EOL> "<STR_LIT>" , <EOL> bindings = { '<STR_LIT>' : label , '<STR_LIT>' : key , '<STR_LIT>' : <NUM_LIT> } ) <EOL> resp = yield stream . read ( ) <EOL> self . assertEqual ( <EOL> resp . data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ key ] [ <NUM_LIT:0> ] [ '<STR_LIT:value>' ] , <NUM_LIT> ) <EOL> @ gen_test <EOL> def test_violate_manual_schema_int ( self ) : <EOL> key = IntegerTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> label = IntegerTestVertex . get_label ( ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> with self . assertRaises ( RuntimeError ) : <EOL> stream = yield connection . execute_query ( <EOL> "<STR_LIT>" , <EOL> bindings = { '<STR_LIT>' : label , '<STR_LIT>' : key , '<STR_LIT>' : '<STR_LIT:hello>' } ) <EOL> resp = yield stream . read ( ) <EOL> @ gen_test <EOL> def test_violate_manual_schema_long ( self ) : <EOL> key = IntegerTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> label = IntegerTestVertex . get_label ( ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> with self . assertRaises ( RuntimeError ) : <EOL> stream = yield connection . execute_query ( <EOL> "<STR_LIT>" , <EOL> bindings = { '<STR_LIT>' : label , '<STR_LIT>' : key , '<STR_LIT>' : '<STR_LIT:hello>' } ) <EOL> resp = yield stream . read ( ) <EOL> @ gen_test <EOL> def test_violate_manual_schema_short ( self ) : <EOL> key = IntegerTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> label = IntegerTestVertex . get_label ( ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> with self . assertRaises ( RuntimeError ) : <EOL> stream = yield connection . execute_query ( <EOL> "<STR_LIT>" , <EOL> bindings = { '<STR_LIT>' : label , '<STR_LIT>' : key , '<STR_LIT>' : '<STR_LIT:hello>' } ) <EOL> resp = yield stream . read ( ) <EOL> class IntegerTestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val1 = Integer ( ) <EOL> test_val2 = Integer ( ) <EOL> test_val3 = Integer ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class IntegerVertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_integer_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> key = IntegerTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> dt = yield IntegerTestVertex . create ( test_val1 = <NUM_LIT:1> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield IntegerTestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val1 , dt . test_val1 ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> dt = yield IntegerTestVertex . create ( test_val1 = <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield IntegerTestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val1 , <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class LongPropertyTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> klass = Long <EOL> good_cases = ( long_ ( <NUM_LIT:1> ) , long_ ( <NUM_LIT:0> ) , None ) <EOL> bad_cases = ( '<STR_LIT>' , '<STR_LIT:a>' , <NUM_LIT> , [ ] , [ <NUM_LIT:1> ] , { } , { '<STR_LIT:a>' : <NUM_LIT:1> } ) <EOL> class LongTestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val = Long ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class LongVertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_long_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> key = LongTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> dt = yield LongTestVertex . create ( test_val = <NUM_LIT:1> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield LongTestVertex . 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 LongTestVertex . create ( test_val = <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield LongTestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ShortPropertyTestCase ( IntegerPropertyTestCase ) : <EOL> klass = Short <EOL> class ShortTestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val = Short ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ShortVertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_short_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> key = ShortTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> dt = yield ShortTestVertex . create ( test_val = <NUM_LIT:1> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield ShortTestVertex . 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 ShortTestVertex . create ( test_val = <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield ShortTestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class PositiveIntegerPropertyTestCase ( IntegerPropertyTestCase ) : <EOL> klass = PositiveInteger <EOL> class PositiveIntegerTestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val = PositiveInteger ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class PositiveIntegerVertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_positive_integer_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> key = PositiveIntegerTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> dt = yield PositiveIntegerTestVertex . create ( test_val = <NUM_LIT:1> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield PositiveIntegerTestVertex . 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 PositiveIntegerTestVertex . create ( test_val = <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield PositiveIntegerTestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class PositiveLongPropertyTestCase ( LongPropertyTestCase ) : <EOL> klass = PositiveLong <EOL> class PositiveLongTestVertex ( Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> test_val = PositiveLong ( ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class PositiveLongVertexTestCase ( GraphPropertyBaseClassTestCase ) : <EOL> @ gen_test <EOL> def test_positive_long_io ( self ) : <EOL> print_ ( "<STR_LIT>" ) <EOL> key = PositiveLongTestVertex . get_property_by_name ( '<STR_LIT>' ) <EOL> yield create_key ( key , '<STR_LIT>' ) <EOL> dt = yield PositiveLongTestVertex . create ( test_val = <NUM_LIT:1> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield PositiveLongTestVertex . 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 PositiveLongTestVertex . create ( test_val = <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" % dt ) <EOL> dt2 = yield PositiveLongTestVertex . get ( dt . _id ) <EOL> print_ ( "<STR_LIT>" % dt2 ) <EOL> self . assertEqual ( dt2 . test_val , <NUM_LIT:2> ) <EOL> print_ ( "<STR_LIT>" ) <EOL> yield dt2 . delete ( ) </s>
