<s> from datetime import datetime <EOL> from unittest import skip <EOL> from uuid import uuid4 <EOL> from thunderdome . gremlin import ThunderdomeGremlinException <EOL> from thunderdome . tests . base import BaseThunderdomeTestCase <EOL> from thunderdome . models import Vertex <EOL> from thunderdome import properties <EOL> from thunderdome import gremlin <EOL> class GroovyTestModel ( Vertex ) : <EOL> text = properties . Text ( ) <EOL> get_self = gremlin . GremlinMethod ( ) <EOL> cm_get_self = gremlin . GremlinMethod ( method_name = '<STR_LIT>' , classmethod = True ) <EOL> return_default = gremlin . GremlinValue ( method_name = '<STR_LIT>' , defaults = { '<STR_LIT>' : lambda : <NUM_LIT> } ) <EOL> return_list = gremlin . GremlinValue ( property = <NUM_LIT:1> ) <EOL> return_value = gremlin . GremlinValue ( ) <EOL> arg_test1 = gremlin . GremlinValue ( ) <EOL> arg_test2 = gremlin . GremlinValue ( ) <EOL> class TestMethodLoading ( BaseThunderdomeTestCase ) : <EOL> def test_method_loads_and_works ( self ) : <EOL> v1 = GroovyTestModel . create ( text = '<STR_LIT>' ) <EOL> v2 = v1 . get_self ( ) <EOL> assert v1 . vid == v2 [ <NUM_LIT:0> ] . vid <EOL> v3 = v1 . cm_get_self ( v1 . eid ) <EOL> assert v1 . vid == v3 [ <NUM_LIT:0> ] . vid <EOL> class TestMethodArgumentHandling ( BaseThunderdomeTestCase ) : <EOL> def test_callable_defaults ( self ) : <EOL> """<STR_LIT>""" <EOL> v1 = GroovyTestModel . create ( text = '<STR_LIT>' ) <EOL> assert v1 . return_default ( ) == <NUM_LIT> <EOL> def test_gremlin_value_enforces_single_object_returned ( self ) : <EOL> """<STR_LIT>""" <EOL> v1 = GroovyTestModel . create ( text = '<STR_LIT>' ) <EOL> with self . assertRaises ( ThunderdomeGremlinException ) : <EOL> v1 . return_list <EOL> def test_type_conversion ( self ) : <EOL> """<STR_LIT>""" <EOL> v1 = GroovyTestModel . create ( text = '<STR_LIT>' ) <EOL> now = datetime . now ( ) <EOL> assert v1 . return_value ( now ) == properties . DateTime ( ) . to_database ( now ) <EOL> uu = uuid4 ( ) <EOL> assert v1 . return_value ( uu ) == properties . UUID ( ) . to_database ( uu ) <EOL> def test_initial_arg_name_isnt_set ( self ) : <EOL> """<STR_LIT>""" <EOL> v = GroovyTestModel . create ( text = '<STR_LIT>' ) <EOL> assert v == v . arg_test1 ( ) <EOL> assert v == v . arg_test2 ( ) </s>
