예제 #1
0
    def test_creds_secret_can_be_overwritten_repo_info(self, monkeypatch):
        task = GetRepoInfo(token_secret="MY_SECRET")

        req = MagicMock()
        monkeypatch.setattr("prefect.tasks.github.repos.requests", req)

        with set_temporary_config({"cloud.use_local_secrets": True}):
            with prefect.context(secrets=dict(MY_SECRET={"key": 42})):
                task.run(repo="org/repo")

        assert req.get.call_args[1]["headers"][
            "AUTHORIZATION"] == "token {'key': 42}"
예제 #2
0
파일: test_repos.py 프로젝트: sanjc/prefect
    def test_creds_are_pulled_from_secret_at_runtime_repo_info(
            self, monkeypatch):
        task = GetRepoInfo(token_secret="GITHUB_ACCESS_TOKEN")

        req = MagicMock()
        monkeypatch.setattr("prefect.tasks.github.repos.requests", req)

        with prefect.context(secrets=dict(GITHUB_ACCESS_TOKEN={"key": 42})):
            task.run(repo="org/repo")

        assert req.get.call_args[1]["headers"][
            "AUTHORIZATION"] == "token {'key': 42}"
예제 #3
0
    def test_creds_are_pulled_from_secret_at_runtime(self, monkeypatch):
        task = GetRepoInfo()

        req = MagicMock()
        monkeypatch.setattr("prefect.tasks.github.repos.requests", req)

        with set_temporary_config({"cloud.use_local_secrets": True}):
            with prefect.context(secrets=dict(
                    GITHUB_ACCESS_TOKEN={"key": 42})):
                task.run(repo="org/repo")

        assert req.get.call_args[1]["headers"][
            "AUTHORIZATION"] == "token {'key': 42}"
예제 #4
0
 def test_repo_is_required_eventually(self):
     task = GetRepoInfo()
     with pytest.raises(ValueError) as exc:
         task.run()
     assert "repo" in str(exc.value)
예제 #5
0
파일: test_repos.py 프로젝트: sanjc/prefect
 def test_repo_is_required_eventually(self):
     task = GetRepoInfo()
     with pytest.raises(ValueError, match="repo"):
         task.run()