class TestConfigModel(TestCase): filename = "config.test" std_cfg = [ { 'name': 'MAIN', 'items': [ dict(header='header', value='value'), dict(header='header2', value='value2'), dict(header='header3', value='value3'), ] } ] def setUp(self): TestConfigCreater() self.config = Config(self.filename) def test_to_dict(self): to_dict = self.config.to_dict() self.assertEqual(to_dict, self.std_cfg) def test_delete(self): mutate_cfg = copy.deepcopy(self.std_cfg) # remove row from items on mutate_cfg[0]['items'] = mutate_cfg[0]['items'][1:] self.config.delete(*('MAIN', 'header')) to_dict = self.config.to_dict() self.assertEqual(to_dict, mutate_cfg) def test_edit(self): mutate_cfg = copy.deepcopy(self.std_cfg) mutate_cfg[0]['items'][0] = dict(header='header', value='value23') # change row from items on dict(header='header23', value='value23') self.config.edit(*('MAIN', 'header', 'value23')) to_dict = self.config.to_dict() self.assertEqual(to_dict, mutate_cfg)
def setUp(self): TestConfigCreater() self.config = Config(self.filename)