def test_parse_volume_spec_internal_and_external(self): spec = parse_volume_spec('external:interval') self.assertEqual(spec, ('external', 'interval', 'rw'))
def test_building_volume_binding_with_home(self): os.environ["HOME"] = "/home/user" binding = build_volume_binding(parse_volume_spec("~:/home/user")) self.assertEqual(binding, ("/home/user", dict(bind="/home/user", ro=False)))
def test_parse_volume_spec_only_one_path(self): spec = parse_volume_spec('/the/volume') self.assertEqual(spec, (None, '/the/volume', 'rw'))
def test_build_volume_binding_with_environ(self): os.environ["VOLUME_PATH"] = "/opt" binding = build_volume_binding(parse_volume_spec("${VOLUME_PATH}:/opt")) self.assertEqual(binding, ("/opt", dict(bind="/opt", ro=False)))
def test_parse_volume_bad_mode(self): with self.assertRaises(ConfigError): parse_volume_spec('one:two:notrw')
def test_build_volume_binding_with_environ(self): os.environ['VOLUME_PATH'] = '/opt' binding = build_volume_binding(parse_volume_spec('${VOLUME_PATH}:/opt')) self.assertEqual(binding, ('/opt', dict(bind='/opt', ro=False)))
def test_building_volume_binding_with_home(self): os.environ['HOME'] = '/home/user' binding = build_volume_binding(parse_volume_spec('~:/home/user')) self.assertEqual( binding, ('/home/user', dict(bind='/home/user', ro=False)))
def test_parse_volume_spec_only_one_path(self): spec = parse_volume_spec("/the/volume") self.assertEqual(spec, (None, "/the/volume", "rw"))
def test_build_volume_binding(self): binding = build_volume_binding(parse_volume_spec('/outside:/inside')) self.assertEqual( binding, ('/outside', dict(bind='/inside', ro=False)))
def test_parse_volume_spec_too_many_parts(self): with self.assertRaises(ConfigError): parse_volume_spec('one:two:three:four')
def test_parse_volume_spec_with_mode(self): spec = parse_volume_spec('external:interval:ro') self.assertEqual(spec, ('external', 'interval', 'ro'))
def test_parse_volume_spec_internal_and_external(self): spec = parse_volume_spec("external:interval") self.assertEqual(spec, ("external", "interval", "rw"))
def test_parse_volume_spec_with_mode(self): spec = parse_volume_spec("external:interval:ro") self.assertEqual(spec, ("external", "interval", "ro"))
def test_build_volume_binding(self): binding = build_volume_binding(parse_volume_spec("/outside:/inside")) self.assertEqual(binding, ("/outside", dict(bind="/inside", ro=False)))