Esempio n. 1
0
    def test_task_spec_from_local_path(self) -> None:
        with patch_repo_loader_deps(DETACHED_TASK_SPEC) as mocks:
            loader = loaders.RepoLoader(TASK_SPEC_PATH)

        assert loader.task_spec == DETACHED_TASK_SPEC
        mocks.read_from_url.assert_not_called()
        mocks.read_file.assert_called_once_with(Path(TASK_SPEC_PATH))
        mocks.sync_git_repo.assert_called_once_with(TEST_URL)
Esempio n. 2
0
    def test_task_spec_from_url(self) -> None:
        task_spec_url = "https://example.com/qwikstart.yml"
        with patch_repo_loader_deps(DETACHED_TASK_SPEC) as mocks:
            loader = loaders.RepoLoader(task_spec_url)

        assert loader.task_spec == DETACHED_TASK_SPEC
        mocks.read_from_url.assert_called_once_with(task_spec_url)
        mocks.read_file.assert_not_called()
        mocks.sync_git_repo.assert_called_once_with(TEST_URL)
Esempio n. 3
0
 def test_repo_path(self) -> None:
     repo_path = Path("/path/to/repo")
     with patch_repo_loader_deps(DETACHED_TASK_SPEC, repo_path=repo_path):
         loader = loaders.RepoLoader(TASK_SPEC_PATH)
     assert loader.repo_path == repo_path
Esempio n. 4
0
 def test_remote_task_spec_without_source_url(self) -> None:
     task_spec_url = "https://example.com/qwikstart.yml"
     with patch_repo_loader_deps({}) as mocks:
         with pytest.raises(RepoLoaderError):
             loaders.RepoLoader(task_spec_url)
     mocks.sync_git_repo.assert_not_called()
Esempio n. 5
0
 def test_repo_path_defaults_to_spec_path_parent(self) -> None:
     self.fs.create_file("/path/to/file.txt", contents="{}")
     loader = loaders.RepoLoader("/path/to/file.txt")
     assert loader.repo_path == Path("/path/to")
Esempio n. 6
0
 def test_unknown_file_type(self) -> None:
     self.fs.create_file("/path/to/file.txt", contents="this: is: invalid")
     with pytest.raises(TaskParserError):
         loaders.RepoLoader("/path/to/file.txt")
Esempio n. 7
0
 def test_resolve_directory(self) -> None:
     self.fs.create_file("/path/containing/qwikstart.yml",
                         contents='{"a": 1}')
     loader = loaders.RepoLoader("/path/containing/")
     assert loader.task_spec == {"a": 1}
Esempio n. 8
0
 def test_resolve_file(self) -> None:
     self.fs.create_file("/path/to/file.yml", contents='{"a": 1}')
     loader = loaders.RepoLoader("/path/to/file.yml")
     assert loader.task_spec == {"a": 1}