Пример #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'
Пример #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'
Пример #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
Пример #4
0
 def test_keyfile_parent(self):
     parent = BaseConfig(BaseSchema(), key_filename='asdf.txt')
     child = BaseConfig(BaseSchema(), parent)
     assert child._keyfile is parent._keyfile
Пример #5
0
 def test_key_filename_none_ctor(self):
     cfg = BaseConfig(BaseSchema())
     assert cfg._key_filename is BaseConfig.DEFAULT_CINCOKEY_FILEPATH
Пример #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'
Пример #7
0
 def test_get_field_dynamic(self):
     schema = BaseSchema()
     config = BaseConfig(schema)
     config._fields['hello'] = 'world'
     assert config._get_field('hello') == 'world'
Пример #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'
Пример #9
0
    def test_add_field_failed(self):
        schema = BaseSchema()
        config = BaseConfig(schema)

        with pytest.raises(TypeError):
            config._add_field('hello', 'world')
Пример #10
0
    def test_get_field_base(self):
        schema = BaseSchema()
        schema._fields['hello'] = 'world'
        config = BaseConfig(schema)

        assert config._get_field('hello') == 'world'
Пример #11
0
 def test_setkey(self):
     schema = BaseSchema()
     schema.__setkey__(None, 'hello')
     assert schema._key == 'hello'
Пример #12
0
 def test_get_field_no_exists(self):
     schema = BaseSchema()
     assert schema._get_field('hello') is None
Пример #13
0
 def test_get_field_exists(self):
     schema = BaseSchema()
     schema._fields['hello'] = 'x'
     assert schema._get_field('hello') == 'x'
Пример #14
0
 def test_add_field_other(self):
     schema = BaseSchema()
     assert schema._add_field('hello', 'world') == 'world'
Пример #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')