2020-12-25 21:56:42 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from tutor import bindmounts
|
|
|
|
from tutor.exceptions import TutorError
|
|
|
|
|
|
|
|
|
|
|
|
class BindMountsTests(unittest.TestCase):
|
2021-02-25 08:09:14 +00:00
|
|
|
def test_get_name(self) -> None:
|
2020-12-25 21:56:42 +00:00
|
|
|
self.assertEqual("venv", bindmounts.get_name("/openedx/venv"))
|
|
|
|
self.assertEqual("venv", bindmounts.get_name("/openedx/venv/"))
|
|
|
|
|
2021-02-25 08:09:14 +00:00
|
|
|
def test_get_name_root_folder(self) -> None:
|
2020-12-25 21:56:42 +00:00
|
|
|
with self.assertRaises(TutorError):
|
|
|
|
bindmounts.get_name("/")
|
|
|
|
with self.assertRaises(TutorError):
|
|
|
|
bindmounts.get_name("")
|
|
|
|
|
2021-02-25 08:09:14 +00:00
|
|
|
def test_parse_volumes(self) -> None:
|
2020-12-25 21:56:42 +00:00
|
|
|
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)
|