def test_get_app_service_ignore_hidden_templates(self): """Test the _get_app_service method ignore templates files who's name starts with and underscore. """ lkp = AppsLookupModule() service_path = "apps/learninglocker/templates/services/app" expected = { "name": "app", "templates": [ "apps/learninglocker/templates/services/app/dc_api.yml.j2", "apps/learninglocker/templates/services/app/dc_ui.yml.j2", "apps/learninglocker/templates/services/app/dc_worker.yml.j2", "apps/learninglocker/templates/services/app/job_storage.yml.j2", "apps/learninglocker/templates/services/app/secret.yml.j2", "apps/learninglocker/templates/services/app/svc_api.yml.j2", "apps/learninglocker/templates/services/app/svc_ui.yml.j2", ], "configs": [], "environment_variables": "apps/learninglocker/templates/services/app/_env.yml.j2", } self.assertEqual(lkp._get_app_service(service_path), expected)
def test_get_app_service_with_envs_and_no_configs(self): """Test the _get_app_service method for a service with a specific environment but no configuration. """ lkp = AppsLookupModule() service_path = "apps/learninglocker/templates/services/xapi" expected = { "name": "xapi", "templates": [ "apps/learninglocker/templates/services/xapi/dc.yml.j2", "apps/learninglocker/templates/services/xapi/secret.yml.j2", "apps/learninglocker/templates/services/xapi/svc.yml.j2", ], "configs": [], "environment_variables": "apps/learninglocker/templates/services/xapi/_env.yml.j2", } self.assertEqual(lkp._get_app_service(service_path), expected)
def test_get_app_service_without_envs_and_configs(self): """Test the _get_app_service method for a service without specific environment or configuration. """ lkp = AppsLookupModule() service_path = "apps/learninglocker/templates/services/mongodb" expected = { "name": "mongodb", "templates": [ "apps/learninglocker/templates/services/mongodb/dc.yml.j2", "apps/learninglocker/templates/services/mongodb/ep.yml.j2", "apps/learninglocker/templates/services/mongodb/secret.yml.j2", "apps/learninglocker/templates/services/mongodb/svc.yml.j2", ], "configs": [], "environment_variables": None, } self.assertEqual(lkp._get_app_service(service_path), expected)
def test_get_app_service_without_envs_but_configs(self): """Test the _get_app_service method for a service with no specific environment but a configuration. """ lkp = AppsLookupModule() service_path = "apps/learninglocker/templates/services/nginx" expected = { "name": "nginx", "templates": [ "apps/learninglocker/templates/services/nginx/dc.yml.j2", "apps/learninglocker/templates/services/nginx/route.yml.j2", "apps/learninglocker/templates/services/nginx/svc.yml.j2", ], "configs": [ "apps/learninglocker/templates/services/nginx/configs/default.conf.j2" ], "environment_variables": None, } self.assertEqual(lkp._get_app_service(service_path), expected)