mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-04 12:18:17 +00:00 
			
		
		
		
	Finished integration test
This commit is contained in:
		@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					# tests/integration/test_get_app_conf_paths.py
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
@@ -56,6 +58,7 @@ class TestGetAppConfPaths(unittest.TestCase):
 | 
				
			|||||||
            if 'tests' in Path(dirpath).parts:
 | 
					            if 'tests' in Path(dirpath).parts:
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            for fname in files:
 | 
					            for fname in files:
 | 
				
			||||||
 | 
					                # ignore .py and .sh files
 | 
				
			||||||
                if fname.endswith(('.py', '.sh')):
 | 
					                if fname.endswith(('.py', '.sh')):
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                file_path = Path(dirpath) / fname
 | 
					                file_path = Path(dirpath) / fname
 | 
				
			||||||
@@ -96,14 +99,25 @@ class TestGetAppConfPaths(unittest.TestCase):
 | 
				
			|||||||
        for dotted, occs in self.variable_paths.items():
 | 
					        for dotted, occs in self.variable_paths.items():
 | 
				
			||||||
            with self.subTest(path=dotted):
 | 
					            with self.subTest(path=dotted):
 | 
				
			||||||
                found = False
 | 
					                found = False
 | 
				
			||||||
                # credentials.*: check preloaded schemas
 | 
					                # credentials.*: zuerst in defaults_applications prüfen, dann im Schema
 | 
				
			||||||
                if dotted.startswith('credentials.'):
 | 
					                if dotted.startswith('credentials.'):
 | 
				
			||||||
                    key = dotted.split('.',1)[1]
 | 
					                    key = dotted.split('.', 1)[1]
 | 
				
			||||||
 | 
					                    # 1) defaults_applications[app_id].credentials
 | 
				
			||||||
 | 
					                    for aid, cfg in self.defaults_app.items():
 | 
				
			||||||
 | 
					                        creds = cfg.get('credentials', {})
 | 
				
			||||||
 | 
					                        if isinstance(creds, dict) and key in creds:
 | 
				
			||||||
 | 
					                            found = True
 | 
				
			||||||
 | 
					                            break
 | 
				
			||||||
 | 
					                    if found:
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    # 2) role_schema.credentials
 | 
				
			||||||
                    for aid, schema in self.role_schemas.items():
 | 
					                    for aid, schema in self.role_schemas.items():
 | 
				
			||||||
                        creds = schema.get('credentials', {})
 | 
					                        creds = schema.get('credentials', {})
 | 
				
			||||||
                        if isinstance(creds, dict) and key in creds:
 | 
					                        if isinstance(creds, dict) and key in creds:
 | 
				
			||||||
                            found = True; break
 | 
					                            found = True
 | 
				
			||||||
                    if found: continue
 | 
					                            break
 | 
				
			||||||
 | 
					                    if found:
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
                # images.*: any images dict
 | 
					                # images.*: any images dict
 | 
				
			||||||
                if dotted.startswith('images.'):
 | 
					                if dotted.startswith('images.'):
 | 
				
			||||||
                    if any(isinstance(cfg.get('images'), dict) for cfg in self.defaults_app.values()):
 | 
					                    if any(isinstance(cfg.get('images'), dict) for cfg in self.defaults_app.values()):
 | 
				
			||||||
@@ -121,7 +135,8 @@ class TestGetAppConfPaths(unittest.TestCase):
 | 
				
			|||||||
                for aid, cfg in self.defaults_app.items():
 | 
					                for aid, cfg in self.defaults_app.items():
 | 
				
			||||||
                    try:
 | 
					                    try:
 | 
				
			||||||
                        self.assertNested(cfg, dotted, aid)
 | 
					                        self.assertNested(cfg, dotted, aid)
 | 
				
			||||||
                        found = True; break
 | 
					                        found = True
 | 
				
			||||||
 | 
					                        break
 | 
				
			||||||
                    except AssertionError:
 | 
					                    except AssertionError:
 | 
				
			||||||
                        pass
 | 
					                        pass
 | 
				
			||||||
                if not found:
 | 
					                if not found:
 | 
				
			||||||
@@ -138,12 +153,17 @@ class TestGetAppConfPaths(unittest.TestCase):
 | 
				
			|||||||
            pass
 | 
					            pass
 | 
				
			||||||
        # users.* fallback
 | 
					        # users.* fallback
 | 
				
			||||||
        if dotted.startswith('users.'):
 | 
					        if dotted.startswith('users.'):
 | 
				
			||||||
            sub = dotted.split('.',1)[1]
 | 
					            sub = dotted.split('.', 1)[1]
 | 
				
			||||||
            if sub in self.defaults_users:
 | 
					            if sub in self.defaults_users:
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
        # credentials.* fallback
 | 
					        # credentials.* fallback: defaults_applications, dann Schema
 | 
				
			||||||
        if dotted.startswith('credentials.'):
 | 
					        if dotted.startswith('credentials.'):
 | 
				
			||||||
            key = dotted.split('.',1)[1]
 | 
					            key = dotted.split('.', 1)[1]
 | 
				
			||||||
 | 
					            # 1) defaults_applications[app_id].credentials
 | 
				
			||||||
 | 
					            creds_cfg = cfg.get('credentials', {})
 | 
				
			||||||
 | 
					            if isinstance(creds_cfg, dict) and key in creds_cfg:
 | 
				
			||||||
 | 
					                return
 | 
				
			||||||
 | 
					            # 2) schema
 | 
				
			||||||
            schema = self.role_schemas.get(app_id, {})
 | 
					            schema = self.role_schemas.get(app_id, {})
 | 
				
			||||||
            creds = schema.get('credentials', {})
 | 
					            creds = schema.get('credentials', {})
 | 
				
			||||||
            self.assertIn(key, creds, f"Credential '{key}' missing for app '{app_id}'")
 | 
					            self.assertIn(key, creds, f"Credential '{key}' missing for app '{app_id}'")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user