def test_When_loading_a_yml_file_It_creates_the_correct_data_structure(self):

    conf = BaseConfig(file=self.path)
    self.assertEquals(False, conf.has('foo'))
    conf.set('foo', 'bar')
    self.assertEquals('bar', conf.get('foo'))
    conf.save()

    conf = BaseConfig(file=self.path)
    self.assertEquals('bar', conf.get('foo'))
Пример #2
0
 def setUp(self):
   testConfig = {
       'main': {
           'test': 'testContent',
           'isMaster': True,
           'interval': 60,
           'server': 'testServer'
       },
       'othersection': {
           'test': 'testContent2',
           'some': { 'nested': { 'key': 'Some nested content' }}
       }
   }
   self.testBaseConfig = BaseConfig(data=testConfig)
Пример #3
0
    def setUp(self):
        testConfig = '''main:
  test: testContent
  isMaster: true
  interval: 60
  server: testServer

othersection:
  test: testContent2
  some:
    nested:
      key: Some nested content
'''

        fileName = binascii.b2a_hex(os.urandom(15))
        fullFileName = '/tmp/%s.yml' % fileName
        with open(fullFileName, 'w') as text_file:
            text_file.write(testConfig)

        self.testBaseConfig = BaseConfig(file=fullFileName)
        self.fullFileName = fullFileName
Пример #4
0
 def test_When_loading_a_yml_file_explicitly_It_creates_the_correct_data_structure(
         self):
     self.testBaseConfig = BaseConfig()
     self.assertEquals({}, self.testBaseConfig._data)
     self.testBaseConfig.load(self.fullFileName)
     self.checkInternalDataOk()