def test_get_app_services(self): """Test the _get_app_services""" lkp = AppsLookupModule() app_path = "apps/learninglocker" 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", }, { "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, }, { "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, }, { "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( sorted(lkp._get_app_services(app_path), key=lambda x: x.get("name")), expected, )
def test_get_app_services_ignore_non_directories(self): """Test that the _get_app_services method only consider directories in service_dir as services. """ self.fs.create_file("apps/foo/templates/services/foo") lkp = AppsLookupModule() app_path = "apps/foo" self.assertEqual(lkp._get_app_services(app_path), [])