Ejemplo 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'
Ejemplo 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'
Ejemplo 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
Ejemplo 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
Ejemplo n.º 5
0
 def test_key_filename_none_ctor(self):
     cfg = BaseConfig(BaseSchema())
     assert cfg._key_filename is BaseConfig.DEFAULT_CINCOKEY_FILEPATH
Ejemplo 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'
Ejemplo n.º 7
0
 def test_get_field_dynamic(self):
     schema = BaseSchema()
     config = BaseConfig(schema)
     config._fields['hello'] = 'world'
     assert config._get_field('hello') == 'world'
Ejemplo 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'
Ejemplo n.º 9
0
    def test_add_field_failed(self):
        schema = BaseSchema()
        config = BaseConfig(schema)

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

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