|
1 | 1 | from __future__ import absolute_import
|
2 | 2 | import unittest
|
| 3 | +import sys |
| 4 | +import os |
3 | 5 |
|
4 | 6 | from six.moves import urllib
|
5 | 7 |
|
|
9 | 11 | from cwltool.load_tool import load_tool
|
10 | 12 | from cwltool.main import main
|
11 | 13 | from cwltool.workflow import defaultMakeTool
|
| 14 | +from cwltool.resolver import resolve_local |
12 | 15 |
|
| 16 | +if sys.version_info < (3, 4): |
| 17 | + from pathlib2 import Path |
| 18 | +else: |
| 19 | + from pathlib import Path |
| 20 | + |
| 21 | +from .util import get_data |
13 | 22 |
|
14 | 23 | class FetcherTest(unittest.TestCase):
|
15 | 24 | def test_fetcher(self):
|
@@ -56,3 +65,21 @@ def test_resolver(d, a):
|
56 | 65 |
|
57 | 66 | self.assertEquals(0, main(["--print-pre", "--debug", "foo.cwl"], resolver=test_resolver,
|
58 | 67 | fetcher_constructor=TestFetcher))
|
| 68 | + |
| 69 | + |
| 70 | +class ResolverTest(unittest.TestCase): |
| 71 | + def test_resolve_local(self): |
| 72 | + origpath = os.getcwd() |
| 73 | + os.chdir(os.path.join(get_data(""))) |
| 74 | + try: |
| 75 | + root = Path.cwd() |
| 76 | + rooturi = root.as_uri() |
| 77 | + self.assertEqual(rooturi+"/tests/echo.cwl", resolve_local(None, os.path.join("tests", "echo.cwl"))) |
| 78 | + self.assertEqual(rooturi+"/tests/echo.cwl#main", resolve_local(None, os.path.join("tests", "echo.cwl")+"#main")) |
| 79 | + self.assertEqual(rooturi+"/tests/echo.cwl", resolve_local(None, str(root / "tests" / "echo.cwl"))) |
| 80 | + # On Windows and Python 2.7, the left side of this test returns |
| 81 | + # file:///C:/ (uppercase drive letter) and the right side returns |
| 82 | + # file:///c:/ (lowercase drive letter) so force a lowercase comparison. |
| 83 | + self.assertEqual((rooturi+"/tests/echo.cwl#main").lower(), resolve_local(None, str(root / "tests" / "echo.cwl")+"#main").lower()) |
| 84 | + finally: |
| 85 | + os.chdir(origpath) |
0 commit comments