7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-05-28 11:50:49 +00:00
tutor/tests/test_bindmounts.py
Régis Behmo 0a670d7ead refactor: add type annotations
Annotations were generated with pyannotate:
https://github.com/dropbox/pyannotate

We are running in strict mode, which is awesome!

This affects a large part of the code base, which might be an issue for
people running a fork of Tutor. Nonetheless, the behavior should not be
affected. If anything, this process has helped find and resolve a few
type-related bugs. Thus, this is not considered as a breaking change.
2021-03-15 21:46:55 +01:00

32 lines
1022 B
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)