<s> import unittest <EOL> from . testcase import BulbsTestCase <EOL> from bulbs . model import Node , NodeProxy , Relationship , RelationshipProxy <EOL> from bulbs . property import Integer , String , DateTime , Bool <EOL> from bulbs . utils import current_datetime <EOL> class Knows ( Relationship ) : <EOL> label = "<STR_LIT>" <EOL> timestamp = DateTime ( default = current_datetime ) <EOL> class Person ( Node ) : <EOL> element_type = "<STR_LIT>" <EOL> name = String ( nullable = False ) <EOL> age = Integer ( ) <EOL> is_adult = Bool ( ) <EOL> class NodeTestCase ( BulbsTestCase ) : <EOL> def setUp ( self ) : <EOL> indices = self . vertex_index_proxy ( self . index_class , self . client ) <EOL> self . people = NodeProxy ( Person , self . client ) <EOL> self . people . index = indices . get_or_create ( "<STR_LIT>" ) <EOL> self . james = self . people . create ( name = "<STR_LIT>" , age = <NUM_LIT> , is_adult = True ) <EOL> def test_properties ( self ) : <EOL> assert self . james . element_type == "<STR_LIT>" <EOL> assert self . james . name == "<STR_LIT>" <EOL> assert self . james . age == <NUM_LIT> <EOL> assert self . james . is_adult is True <EOL> def test_get ( self ) : <EOL> person = self . people . get ( self . james . eid ) <EOL> assert person == self . james <EOL> def test_get_all ( self ) : <EOL> people = self . people . get_all ( ) <EOL> assert len ( list ( people ) ) > <NUM_LIT:1> <EOL> def test_index_name ( self ) : <EOL> index_name = self . people . index . index_name <EOL> assert index_name == "<STR_LIT>" <EOL> class RelationshipTestCase ( BulbsTestCase ) : <EOL> def setUp ( self ) : <EOL> indicesV = self . vertex_index_proxy ( self . index_class , self . client ) <EOL> indicesE = self . edge_index_proxy ( self . index_class , self . client ) <EOL> self . people = NodeProxy ( Person , self . client ) <EOL> self . people . index = indicesV . get_or_create ( "<STR_LIT>" ) <EOL> self . knows = RelationshipProxy ( Knows , self . client ) <EOL> self . knows . index = indicesE . get_or_create ( "<STR_LIT>" ) <EOL> self . james = self . people . create ( name = "<STR_LIT>" , age = <NUM_LIT> ) <EOL> self . julie = self . people . create ( name = "<STR_LIT>" , age = <NUM_LIT> ) <EOL> def test_properties ( self ) : <EOL> self . relationship = self . knows . create ( self . james , self . julie ) <EOL> assert self . relationship . _label == "<STR_LIT>" <EOL> assert self . relationship . outV ( ) . _id == self . james . eid <EOL> assert self . relationship . inV ( ) . _id == self . julie . eid <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . makeSuite ( NodeTestCase ) ) <EOL> suite . addTest ( unittest . makeSuite ( RelationshipTestCase ) ) <EOL> return suite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
