<s> from thunderdome . tests . base import BaseThunderdomeTestCase <EOL> from thunderdome . exceptions import ModelException , ThunderdomeException <EOL> from thunderdome . models import Vertex , Edge <EOL> from thunderdome import properties , ValidationError <EOL> import thunderdome <EOL> from thunderdome . tests . models import TestModel <EOL> class WildDBNames ( Vertex ) : <EOL> content = properties . Text ( db_field = '<STR_LIT>' ) <EOL> numbers = properties . Integer ( db_field = '<STR_LIT>' ) <EOL> class Stuff ( Vertex ) : <EOL> num = properties . Integer ( ) <EOL> class TestModelClassFunction ( BaseThunderdomeTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_column_attributes_handled_correctly ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertHasAttr ( TestModel , '<STR_LIT>' ) <EOL> self . assertHasAttr ( TestModel , '<STR_LIT>' ) <EOL> self . assertHasAttr ( TestModel , '<STR_LIT:text>' ) <EOL> inst = TestModel ( ) <EOL> self . assertHasAttr ( inst , '<STR_LIT>' ) <EOL> self . assertHasAttr ( inst , '<STR_LIT:text>' ) <EOL> self . assertIsNone ( inst . vid ) <EOL> self . assertIsNone ( inst . text ) <EOL> def test_db_map ( self ) : <EOL> """<STR_LIT>""" <EOL> db_map = WildDBNames . _db_map <EOL> self . assertEquals ( db_map [ '<STR_LIT>' ] , '<STR_LIT:content>' ) <EOL> self . assertEquals ( db_map [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_attempting_to_make_duplicate_column_names_fails ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ModelException ) : <EOL> class BadNames ( Vertex ) : <EOL> words = properties . Text ( ) <EOL> content = properties . Text ( db_field = '<STR_LIT>' ) <EOL> def test_value_managers_are_keeping_model_instances_isolated ( self ) : <EOL> """<STR_LIT>""" <EOL> inst1 = TestModel ( count = <NUM_LIT:5> ) <EOL> inst2 = TestModel ( count = <NUM_LIT:7> ) <EOL> self . assertNotEquals ( inst1 . count , inst2 . count ) <EOL> self . assertEquals ( inst1 . count , <NUM_LIT:5> ) <EOL> self . assertEquals ( inst2 . count , <NUM_LIT:7> ) <EOL> class RenamedTest ( thunderdome . Vertex ) : <EOL> element_type = '<STR_LIT>' <EOL> vid = thunderdome . UUID ( primary_key = True ) <EOL> data = thunderdome . Text ( ) <EOL> class TestManualTableNaming ( BaseThunderdomeTestCase ) : <EOL> def test_proper_table_naming ( self ) : <EOL> assert RenamedTest . get_element_type ( ) == '<STR_LIT>' <EOL> class BaseAbstractVertex ( thunderdome . Vertex ) : <EOL> __abstract__ = True <EOL> data = thunderdome . Text ( ) <EOL> class DerivedAbstractVertex ( BaseAbstractVertex ) : pass <EOL> class TestAbstractElementAttribute ( BaseThunderdomeTestCase ) : <EOL> def test_abstract_property_is_not_inherited ( self ) : <EOL> assert BaseAbstractVertex . __abstract__ <EOL> assert not DerivedAbstractVertex . __abstract__ <EOL> def test_abstract_element_persistence_methods_fail ( self ) : <EOL> bm = BaseAbstractVertex ( data = '<STR_LIT>' ) <EOL> with self . assertRaises ( ThunderdomeException ) : <EOL> bm . save ( ) <EOL> with self . assertRaises ( ThunderdomeException ) : <EOL> bm . delete ( ) <EOL> with self . assertRaises ( ThunderdomeException ) : <EOL> bm . update ( data = '<STR_LIT>' ) <EOL> class TestValidationVertex ( Vertex ) : <EOL> num = thunderdome . Integer ( required = True ) <EOL> num2 = thunderdome . Integer ( required = True ) <EOL> def validate_num ( self , value ) : <EOL> val = self . validate_field ( '<STR_LIT>' , value ) <EOL> return <NUM_LIT:5> <EOL> def validate_num2 ( self , value ) : <EOL> return <NUM_LIT:5> <EOL> class TestValidation ( BaseThunderdomeTestCase ) : <EOL> def test_custom_validation_method ( self ) : <EOL> v = TestValidationVertex . create ( num = <NUM_LIT:6> ) <EOL> assert v . num == <NUM_LIT:5> <EOL> assert v . num2 == <NUM_LIT:5> <EOL> with self . assertRaises ( ValidationError ) : <EOL> TestValidationVertex . create ( ) </s>
