From ff85ae14830ed8bf8d3a28bb89addbdc2a89e881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sun, 7 Mar 2021 22:19:52 +0100 Subject: [PATCH] v2.15.1 --- satella/__init__.py | 2 +- satella/configuration/schema/from_json.py | 2 +- tests/test_configuration/test_schema.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/satella/__init__.py b/satella/__init__.py index f1cd48c3..4135d855 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1 +1 @@ -__version__ = '2.15.1a1' +__version__ = '2.15.1' diff --git a/satella/configuration/schema/from_json.py b/satella/configuration/schema/from_json.py index 954bf7a5..fd61daeb 100644 --- a/satella/configuration/schema/from_json.py +++ b/satella/configuration/schema/from_json.py @@ -9,7 +9,7 @@ from .structs import create_key, Dict def _get_descriptor_for_str(key: str, value: str) -> Descriptor: try: - if value in ('int', 'float', 'str', 'ipv4', 'any', 'bool'): + if value in ('int', 'float', 'str', 'ipv4', 'any', 'bool', 'file'): return create_key(BASE_LOOKUP_TABLE[value](), key, False, None) except KeyError: diff --git a/tests/test_configuration/test_schema.py b/tests/test_configuration/test_schema.py index e1c17be0..699da055 100644 --- a/tests/test_configuration/test_schema.py +++ b/tests/test_configuration/test_schema.py @@ -14,6 +14,17 @@ class Environment(enum.IntEnum): class TestSchema(unittest.TestCase): + def test_file(self): + schema = { + "key": "file" + } + with open('test', 'wb') as f_out: + f_out.write(b'test') + + s = descriptor_from_dict(schema) + + self.assertEqual(s({'key': "test"}), {'key': 'test'}) + def test_caster(self): ps = Caster(Environment) self.assertEqual(ps(0), Environment.PRODUCTION) -- GitLab