def test_zeno_nested_loads_nested_dot_notation_nested_key(self): self.assertEqual(Zeno('Spring.Data.MongoDb').Nested.key, 5243)
def test_zeno_is_equal_dictionary_when_nothing_set_in_constructor(self): self.assertEqual(Zeno(), parsed_yml)
def test_zeno_nested_loads_nested_dot_notation_pass(self): self.assertEqual(Zeno('Spring.Data.MongoDb').password, '!54353Ffesf34')
def test_zeno_nested_loads_nested_dot_notation_replica(self): self.assertEqual(Zeno('Spring.Data.MongoDb').replicaSet, 'FAKE-DB-531')
def test_zeno_nested_loads_nested_dot_notation_encryption(self): self.assertEqual(Zeno('Spring.Data.MongoDb').encryption, True)
def test_zeno_nested_loads_nested_dot_notation_enckey(self): self.assertEqual(Zeno('Spring.Data.MongoDb').encryptionKey, 'FakePassWord!')
def test_zeno_nested_loads_second_first_nested(self): self.assertEqual(Zeno('Spring').Data.second, 1)
def test_zeno_nested_loads_nested_dot_notation_db(self): self.assertEqual(Zeno('Spring.Data.MongoDb').database, 'TESTDB')
def test_zeno_is_equal_dictionary_referencing_third_nested(self): self.assertEqual(Zeno('Spring.Data.MongoDb').Nested, parsed_yml['Spring']['Data']['MongoDb']['Nested'])
def test_zeno_nested_loads_list(self): self.assertEqual(Zeno('Spring').Data.myList, ['first', 'second', 'third'])
def test_zeno_is_equal_dictionary_referencing_first_nested(self): self.assertEqual(Zeno('Spring').Data, parsed_yml['Spring']['Data'])
def test_zeno_is_equal_dictionary(self): self.assertEqual(Zeno('Spring'), parsed_yml['Spring'])
def test_cannot_set_attriute_zeno(self): with self.assertRaises(AttributeError): Zeno().Spring = 1
def test_cannot_set_item_zeno(self): with self.assertRaises(AttributeError): Zeno()['Spring'] = 1
class SuperNested(Configuration): """Specifying section""" __section__ = 'Spring.Data.MongoDb' database = String() encryption = Boolean() encryptionKey = String() password = String() replicaSet = String() class Nested: key = Integer() print(Spring().Data.myList) # ['first', 'second', 'third'] print(Spring().Data.MongoDb.encryption is True) # True print(MyServer().host) # my.server.com print(SuperNested().database) # TESTDB print(SuperNested().Nested.key) # True # this method is used if specifying a class is not ideal for the user zeno = Zeno() print(zeno.Spring.Data.MongoDb.database) # TESTDB # if the constructor is specified, it denotes how to search withing the yml file starting # in the section mongodb withing the data section, within the spring section # in this case it will be all these member variables: database encryption encryptionKey password replicaSet zeno_2 = Zeno('Spring.Data.MongoDb') print(zeno_2.database) # TESTDB