diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-10-06 18:01:36 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-10-09 21:00:42 +0300 |
commit | 3ba601fc4a20d0c9c883562496bd23818029228d (patch) | |
tree | 3d2d4e8224ba011db725fd4c8679b109db317eae | |
parent | 4cd033e8f682f5a5ad2b64bc77b52b28f48e7020 (diff) | |
download | qvisqve-3ba601fc4a20d0c9c883562496bd23818029228d.tar.gz |
Add: ResourceType.get_files
-rw-r--r-- | qvarn/resource_type.py | 4 | ||||
-rw-r--r-- | qvarn/resource_type_tests.py | 25 |
2 files changed, 26 insertions, 3 deletions
diff --git a/qvarn/resource_type.py b/qvarn/resource_type.py index 3740b84..40f8930 100644 --- a/qvarn/resource_type.py +++ b/qvarn/resource_type.py @@ -89,6 +89,10 @@ class ResourceType: subproto = subpaths.get(subpath, {}) return subproto.get('prototype') + def get_files(self): + v = self._versions[-1] + return v.get('files', []) + def load_resource_types(dirname): # pragma: no cover assert dirname is not None diff --git a/qvarn/resource_type_tests.py b/qvarn/resource_type_tests.py index 06c502c..a1fd09a 100644 --- a/qvarn/resource_type_tests.py +++ b/qvarn/resource_type_tests.py @@ -66,7 +66,16 @@ class ResourceTypeTests(unittest.TestCase): 'subbar': '', }, }, + 'blob': { + 'prototype': { + 'blob': 'blob', + 'content-type': '', + }, + }, }, + 'files': [ + 'blob', + ], }, ], } @@ -84,16 +93,26 @@ class ResourceTypeTests(unittest.TestCase): self.assertEqual( rt.get_latest_prototype(), spec['versions'][-1]['prototype']) self.assertEqual(rt.as_dict(), spec) + subpaths = spec['versions'][-1]['subpaths'] self.assertEqual( rt.get_subpaths(), { - 'subfoo': - spec['versions'][-1]['subpaths']['subfoo']['prototype'], - }) + 'subfoo': subpaths['subfoo']['prototype'], + 'blob': subpaths['blob']['prototype'], + }, + ) self.assertEqual( rt.get_subprototype('subfoo'), spec['versions'][-1]['subpaths']['subfoo']['prototype'] ) + self.assertEqual(rt.get_files(), ['blob']) + self.assertEqual( + rt.get_subprototype('blob'), + { + 'blob': 'blob', + 'content-type': '', + } + ) class AddMissingFieldsTests(unittest.TestCase): |