Esempio n. 1
0
 def test_add_field_dynamic(self):
     schema = BaseSchema(dynamic=True)
     config = BaseConfig(schema)
     assert config._add_field('hello', 'world') == 'world'
     assert config._fields['hello'] == 'world'
Esempio n. 2
0
 def test_keyfile_default(self):
     parent = BaseConfig(BaseSchema())
     child = BaseConfig(BaseSchema(), parent)
     assert child._keyfile is parent._keyfile
     assert child._keyfile.filename == '/path/to/cincokey'
Esempio n. 3
0
 def test_keyfile_set(self):
     parent = BaseConfig(BaseSchema(), key_filename='asdf.txt')
     child = BaseConfig(BaseSchema(), parent, key_filename='qwer.txt')
     assert child._keyfile is not parent._keyfile
Esempio n. 4
0
 def test_keyfile_parent(self):
     parent = BaseConfig(BaseSchema(), key_filename='asdf.txt')
     child = BaseConfig(BaseSchema(), parent)
     assert child._keyfile is parent._keyfile
Esempio n. 5
0
 def test_key_filename_none_ctor(self):
     cfg = BaseConfig(BaseSchema())
     assert cfg._key_filename is BaseConfig.DEFAULT_CINCOKEY_FILEPATH
Esempio n. 6
0
 def test_key_filename_set_none(self):
     parent = BaseConfig(BaseSchema(), key_filename='asdf.txt')
     child = BaseConfig(BaseSchema(), parent, key_filename='qwer.txt')
     child._key_filename = None
     assert child._key_filename == 'asdf.txt'
     assert parent._key_filename == 'asdf.txt'
Esempio n. 7
0
 def test_get_field_dynamic(self):
     schema = BaseSchema()
     config = BaseConfig(schema)
     config._fields['hello'] = 'world'
     assert config._get_field('hello') == 'world'
Esempio n. 8
0
 def test_key_filename_ctor(self):
     cfg = BaseConfig(BaseSchema(), key_filename='asdf.txt')
     assert cfg._key_filename == 'asdf.txt'
     assert cfg._BaseConfig__keyfile.filename == 'asdf.txt'
Esempio n. 9
0
    def test_add_field_failed(self):
        schema = BaseSchema()
        config = BaseConfig(schema)

        with pytest.raises(TypeError):
            config._add_field('hello', 'world')
Esempio n. 10
0
    def test_get_field_base(self):
        schema = BaseSchema()
        schema._fields['hello'] = 'world'
        config = BaseConfig(schema)

        assert config._get_field('hello') == 'world'
Esempio n. 11
0
 def test_setkey(self):
     schema = BaseSchema()
     schema.__setkey__(None, 'hello')
     assert schema._key == 'hello'
Esempio n. 12
0
 def test_get_field_no_exists(self):
     schema = BaseSchema()
     assert schema._get_field('hello') is None
Esempio n. 13
0
 def test_get_field_exists(self):
     schema = BaseSchema()
     schema._fields['hello'] = 'x'
     assert schema._get_field('hello') == 'x'
Esempio n. 14
0
 def test_add_field_other(self):
     schema = BaseSchema()
     assert schema._add_field('hello', 'world') == 'world'
Esempio n. 15
0
 def test_add_field_schema(self):
     schema = BaseSchema()
     child = BaseSchema()
     child.__setkey__ = MagicMock()
     schema._add_field('hello', child)
     child.__setkey__.assert_called_once_with(schema, 'hello')