Ejemplo n.º 1
0
 def test_zeno_nested_loads_nested_dot_notation_nested_key(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').Nested.key, 5243)
Ejemplo n.º 2
0
 def test_zeno_is_equal_dictionary_when_nothing_set_in_constructor(self):
     self.assertEqual(Zeno(), parsed_yml)
Ejemplo n.º 3
0
 def test_zeno_nested_loads_nested_dot_notation_pass(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').password, '!54353Ffesf34')
Ejemplo n.º 4
0
 def test_zeno_nested_loads_nested_dot_notation_replica(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').replicaSet, 'FAKE-DB-531')
Ejemplo n.º 5
0
 def test_zeno_nested_loads_nested_dot_notation_encryption(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').encryption, True)
Ejemplo n.º 6
0
 def test_zeno_nested_loads_nested_dot_notation_enckey(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').encryptionKey, 'FakePassWord!')
Ejemplo n.º 7
0
 def test_zeno_nested_loads_second_first_nested(self):
     self.assertEqual(Zeno('Spring').Data.second, 1)
Ejemplo n.º 8
0
 def test_zeno_nested_loads_nested_dot_notation_db(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').database, 'TESTDB')
Ejemplo n.º 9
0
 def test_zeno_is_equal_dictionary_referencing_third_nested(self):
     self.assertEqual(Zeno('Spring.Data.MongoDb').Nested, parsed_yml['Spring']['Data']['MongoDb']['Nested'])
Ejemplo n.º 10
0
 def test_zeno_nested_loads_list(self):
     self.assertEqual(Zeno('Spring').Data.myList, ['first', 'second', 'third'])
Ejemplo n.º 11
0
 def test_zeno_is_equal_dictionary_referencing_first_nested(self):
     self.assertEqual(Zeno('Spring').Data, parsed_yml['Spring']['Data'])
Ejemplo n.º 12
0
 def test_zeno_is_equal_dictionary(self):
     self.assertEqual(Zeno('Spring'), parsed_yml['Spring'])
Ejemplo n.º 13
0
 def test_cannot_set_attriute_zeno(self):
     with self.assertRaises(AttributeError):
         Zeno().Spring = 1
Ejemplo n.º 14
0
 def test_cannot_set_item_zeno(self):
     with self.assertRaises(AttributeError):
         Zeno()['Spring'] = 1
Ejemplo n.º 15
0
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