def test_restore_all_backup(mocker): from console.services.app_actions.app_deploy import MarketService service = ServiceSourceInfo() service.service_id = "dummy service_id" market_service = MarketService(None, service, "dummy version") backup = TenantServiceBackup() market_service.restore_func = { "deploy_version": market_service.dummy_func, "app_version": market_service.dummy_func, "image": market_service.dummy_func, "slug_path": market_service.dummy_func, "envs": market_service.dummy_func, "connect_infos": market_service.dummy_func, "ports": market_service.dummy_func, "volumes": market_service.dummy_func, "probe": market_service.dummy_func, "dep_services": market_service.dummy_func, "dep_volumes": market_service.dummy_func, "plugins": market_service.dummy_func, } logger.debug("market_service.async_action: {}".format( market_service.async_action)) market_service.restore_backup(backup) assert 0 == market_service.async_action assert 0 == market_service.get_async_action()
def __save_service_source(self, tenant, service, service_source): if service_source: service_source.pop("ID") new_service_source = ServiceSourceInfo(**service_source) new_service_source.service_id = service.service_id new_service_source.team_id = tenant.tenant_id new_service_source.save()
def test_list_by_svc_share_uuids(): tenant_id = "6d1c06e1d9e84d57aeb42ea80d49018a" service_id = "560ca84003254737a426d0bd5f513afd" service_cname = "WordPress" group_id = 20 service = TenantServiceInfo() service.tenant_id = tenant_id service.service_id = service_id service.service_cname = service_cname service.save() service_source = ServiceSourceInfo() service_source.team_id = tenant_id service_source.service_id = service_id service_source.service_share_uuid = "2669c2cec6bc7bf5aab29a0ea2703d66" service_source.save() group_relation = ServiceGroupRelation() group_relation.service_id = service_id group_relation.group_id = group_id group_relation.save() from console.repositories.app import service_repo result = service_repo.list_by_svc_share_uuids( group_id, ["2669c2cec6bc7bf5aab29a0ea2703d66"]) service = result[0] assert service.get("service_id") == service_id assert service.get("service_cname") == service_cname
def test_update_changed(mocker): from console.services.app_actions.app_deploy import MarketService service = ServiceSourceInfo() service.service_id = "dummy service_id" market_service = MarketService(None, service, "dummy version") market_service._update_changed() for k, v in list(market_service.changed.items()): continue