6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-26 03:27:28 +00:00
tutor/tests/test_bindmounts.py
Régis Behmo 6d92fe2d4a fix: crash during local quickstart -p
When running `tutor local quickstart -p` we were getting the following error:

    Usage: custom [OPTIONS] ARGS...
    Try 'custom --help' for help.

    Error: Missing argument 'ARGS...'.

The docker-compose command sometimes accept a single command ("pull") with zero
argument.

See: https://discuss.overhang.io/t/local-quickstart-not-working-when-pullimages-enabled/1526
2021-05-07 17:01:09 +02:00

37 lines
1.2 KiB
Python

import unittest
from tutor import bindmounts
from tutor.exceptions import TutorError
class BindMountsTests(unittest.TestCase):
def test_get_name(self) -> None:
self.assertEqual("venv", bindmounts.get_name("/openedx/venv"))
self.assertEqual("venv", bindmounts.get_name("/openedx/venv/"))
def test_get_name_root_folder(self) -> None:
with self.assertRaises(TutorError):
bindmounts.get_name("/")
with self.assertRaises(TutorError):
bindmounts.get_name("")
def test_parse_volumes(self) -> None:
volume_args, non_volume_args = bindmounts.parse_volumes(
[
"run",
"--volume=/openedx/venv",
"-v",
"/tmp/openedx:/openedx",
"lms",
"echo",
"boom",
]
)
self.assertEqual(("/openedx/venv", "/tmp/openedx:/openedx"), volume_args)
self.assertEqual(("run", "lms", "echo", "boom"), non_volume_args)
def test_parse_volumes_empty_list(self) -> None:
volume_args, non_volume_args = bindmounts.parse_volumes([])
self.assertEqual((), volume_args)
self.assertEqual((), non_volume_args)