<s> from django . db import models <EOL> from django . test import TestCase <EOL> from django_fsm import FSMField , transition <EOL> class ProtectedAccessModel ( models . Model ) : <EOL> status = FSMField ( default = '<STR_LIT>' , protected = True ) <EOL> @ transition ( field = status , source = '<STR_LIT>' , target = '<STR_LIT>' ) <EOL> def publish ( self ) : <EOL> pass <EOL> class Meta : <EOL> app_label = '<STR_LIT>' <EOL> class TestDirectAccessModels ( TestCase ) : <EOL> def test_no_direct_access ( self ) : <EOL> instance = ProtectedAccessModel ( ) <EOL> self . assertEqual ( instance . status , '<STR_LIT>' ) <EOL> def try_change ( ) : <EOL> instance . status = '<STR_LIT>' <EOL> self . assertRaises ( AttributeError , try_change ) <EOL> instance . publish ( ) <EOL> instance . save ( ) <EOL> self . assertEqual ( instance . status , '<STR_LIT>' ) </s>
