<s> import os <EOL> import shutil <EOL> import tempfile <EOL> import unittest <EOL> from trac . test import EnvironmentStub <EOL> from trac . upgrades import db39 <EOL> from trac . versioncontrol . api import RepositoryManager <EOL> from trac . versioncontrol . svn_authz import AuthzSourcePolicy <EOL> VERSION = <NUM_LIT> <EOL> class UpgradeTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . env = EnvironmentStub ( path = tempfile . mkdtemp ( ) ) <EOL> self . env . config . filename = os . path . join ( self . env . path , '<STR_LIT>' ) <EOL> AuthzSourcePolicy ( self . env ) <EOL> RepositoryManager ( self . env ) <EOL> def tearDown ( self ) : <EOL> shutil . rmtree ( self . env . path ) <EOL> def test_saves_backup ( self ) : <EOL> """<STR_LIT>""" <EOL> config = self . env . config <EOL> db39 . do_upgrade ( self . env , VERSION , None ) <EOL> self . assertTrue ( os . path . exists ( config . filename + '<STR_LIT>' ) ) <EOL> def test_old_options_not_in_registry ( self ) : <EOL> """<STR_LIT>""" <EOL> config = self . env . config <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_new_options_in_registry ( self ) : <EOL> """<STR_LIT>""" <EOL> config = self . env . config <EOL> self . assertTrue ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertTrue ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertTrue ( config . has_option ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> def test_tracini_values_moved ( self ) : <EOL> """<STR_LIT>""" <EOL> config = self . env . config <EOL> config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> config . save ( ) <EOL> db39 . do_upgrade ( self . env , VERSION , None ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , config . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> def test_default_values_written_to_tracini ( self ) : <EOL> """<STR_LIT>""" <EOL> config = self . env . config <EOL> db39 . do_upgrade ( self . env , VERSION , None ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( config . has_option ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , config . get ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> def suite ( ) : <EOL> return unittest . makeSuite ( UpgradeTestCase ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
