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'
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'
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
def test_keyfile_parent(self): parent = BaseConfig(BaseSchema(), key_filename='asdf.txt') child = BaseConfig(BaseSchema(), parent) assert child._keyfile is parent._keyfile
def test_key_filename_none_ctor(self): cfg = BaseConfig(BaseSchema()) assert cfg._key_filename is BaseConfig.DEFAULT_CINCOKEY_FILEPATH
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'
def test_get_field_dynamic(self): schema = BaseSchema() config = BaseConfig(schema) config._fields['hello'] = 'world' assert config._get_field('hello') == 'world'
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'
def test_add_field_failed(self): schema = BaseSchema() config = BaseConfig(schema) with pytest.raises(TypeError): config._add_field('hello', 'world')
def test_get_field_base(self): schema = BaseSchema() schema._fields['hello'] = 'world' config = BaseConfig(schema) assert config._get_field('hello') == 'world'
def test_setkey(self): schema = BaseSchema() schema.__setkey__(None, 'hello') assert schema._key == 'hello'
def test_get_field_no_exists(self): schema = BaseSchema() assert schema._get_field('hello') is None
def test_get_field_exists(self): schema = BaseSchema() schema._fields['hello'] = 'x' assert schema._get_field('hello') == 'x'
def test_add_field_other(self): schema = BaseSchema() assert schema._add_field('hello', 'world') == 'world'
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')