# Path: xmanager/xm/utils.py
# FLAGS = flags.FLAGS
# ARG_ESCAPER = pattern_matching.match(
#     pattern_matching.Case([ShellSafeArg], lambda v: v.arg),
#     pattern_matching.Case([enum.Enum], lambda v: shlex.quote(str(v.name))),
#     pattern_matching.Case([Any], lambda v: shlex.quote(str(v))),
# )
# class SpecialArg(abc.ABC):
# class ShellSafeArg(SpecialArg):
# def trivial_kwargs_joiner(key: str, value: str) -> str:
# def run_in_asyncio_loop(
#     f: Callable[..., ReturnType]) -> Callable[..., ReturnType]:
#   def decorated(*args, **kwargs) -> ReturnType:
# def find_launch_script_path() -> str:
# def resolve_path_relative_to_launcher(path: str) -> str:


import enum
import unittest
from xmanager.xm import utils
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




async def make_me_a_sandwich() -> str:
  return 'sandwich'


class ResourceType(enum.Enum):
  MINERALS = 1
  VESPEN = 2


class UtilsTest(unittest.TestCase):

  @utils.run_in_asyncio_loop
  async def test_run_in_asyncio_loop(self):
    self.assertEqual(await make_me_a_sandwich(), 'sandwich')

  def test_run_in_asyncio_loop_returns_value(self):
    self.assertEqual(
        utils.run_in_asyncio_loop(make_me_a_sandwich)(), 'sandwich')

  def test_arg_escaper(self):
    self.assertEqual(utils.ARG_ESCAPER(1.0), '1.0')

# Path: xmanager/xm/utils.py
# FLAGS = flags.FLAGS
# ARG_ESCAPER = pattern_matching.match(
#     pattern_matching.Case([ShellSafeArg], lambda v: v.arg),
#     pattern_matching.Case([enum.Enum], lambda v: shlex.quote(str(v.name))),
#     pattern_matching.Case([Any], lambda v: shlex.quote(str(v))),
# )
# class SpecialArg(abc.ABC):
# class ShellSafeArg(SpecialArg):
# def trivial_kwargs_joiner(key: str, value: str) -> str:
# def run_in_asyncio_loop(
#     f: Callable[..., ReturnType]) -> Callable[..., ReturnType]:
#   def decorated(*args, **kwargs) -> ReturnType:
# def find_launch_script_path() -> str:
# def resolve_path_relative_to_launcher(path: str) -> str:


# Path: xmanager/xm/utils_test.py
import enum
import unittest
from xmanager.xm import utils

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




async def make_me_a_sandwich() -> str:
  return 'sandwich'


class ResourceType(enum.Enum):
  MINERALS = 1
  VESPEN = 2


class UtilsTest(unittest.TestCase):

  @utils.run_in_asyncio_loop
  async def test_run_in_asyncio_loop(self):
    self.assertEqual(await make_me_a_sandwich(), 'sandwich')

  def test_run_in_asyncio_loop_returns_value(self):
    self.assertEqual(
        utils.run_in_asyncio_loop(make_me_a_sandwich)(), 'sandwich')

  def test_arg_escaper(self):
    self.assertEqual(utils.ARG_ESCAPER(1.0), '1.0')

    self.assertEqual(utils.ARG_ESCAPER('Jonny Droptable'), "'Jonny Droptable'")