def test_ini_bad_content(self): with self.assertRaises(ini_file.WrongIniContent): ini_file._update_ini_content( ini_content='Some-broken-content', state='present', section='NewSection' )
def test_ini_del_section(self): new_ini_content = ini_file._update_ini_content( ini_content=INI_CONFIG_CONTENT, state='absent', section='SectionTwo') self.assertEqual(new_ini_content, """[SectionOne] Name=Michel """)
def test_ini_delete_option(self): new_ini_content = ini_file._update_ini_content( ini_content=INI_CONFIG_CONTENT, state='absent', section='SectionTwo', option='ConfigName') self.assertEqual( new_ini_content, """[SectionOne] Name=Michel [SectionTwo] OtherName=OtherValue """)
def test_ini_replace_option(self): new_ini_content = ini_file._update_ini_content( ini_content=INI_CONFIG_CONTENT, state='present', section='SectionTwo', option='ConfigName', value=VARIABLE_VALUE) self.assertEqual( new_ini_content, """[SectionOne] Name=Michel [SectionTwo] ConfigName=MICHEL OtherName=OtherValue """)
def test_ini_set_option_in_existing_section(self): new_ini_content = ini_file._update_ini_content( ini_content=INI_CONFIG_CONTENT, state='present', section='SectionTwo', option=VARIABLE_NAME, value=VARIABLE_VALUE) self.assertEqual( new_ini_content, """[SectionOne] Name=Michel [SectionTwo] ConfigName=SomeValue OtherName=OtherValue VARIABLE_NAME=MICHEL """)
def test_ini_set_new_section(self): new_ini_content = ini_file._update_ini_content( ini_content=INI_CONFIG_CONTENT, state='present', # STATE_PRESENT must be equal to 'present' section='NewSection', option=VARIABLE_NAME, value=VARIABLE_VALUE ) self.assertEqual( new_ini_content, """[SectionOne] Name=Michel [SectionTwo] ConfigName=SomeValue OtherName=OtherValue [NewSection] VARIABLE_NAME=MICHEL """ )