Exemplo n.º 1
0
 def test_flow_run_task_with_no_matching_flow(self, client, cloud_api):
     # verify a ValueError is raised if the client returns no flows
     task = FlowRunTask(flow_name="Test Flow", project_name="Test Project")
     client.graphql = MagicMock(return_value=MagicMock(data=MagicMock(
         flow=[])))
     with pytest.raises(ValueError, match="Flow 'Test Flow' not found."):
         task.run()
Exemplo n.º 2
0
    def test_idempotency_key_uses_map_index_if_present(self, client, cloud_api):
        # verify that create_flow_run was called
        task = FlowRunTask(project_name="Test Project", flow_name="Test Flow")

        # verify that run returns the new flow run ID
        with prefect.context(flow_run_id="test-id", map_index=4):
            assert task.run() == "xyz890"

        # verify create_flow_run was called with the correct arguments
        client.create_flow_run.assert_called_once_with(
            flow_id="abc123", idempotency_key="test-id-4", parameters=None, context=None
        )
Exemplo n.º 3
0
    def test_flow_run_task(self, client, server_api):
        # verify that create_flow_run was called
        task = FlowRunTask(flow_name="Test Flow", parameters={"test": "ing"},)
        # verify that run returns the new flow run ID
        assert task.run() == "xyz890"
        # verify the GraphQL query was called with the correct arguments
        query_args = list(client.graphql.call_args_list[0][0][0]["query"].keys())[0]
        assert "Test Flow" in query_args

        # verify create_flow_run was called with the correct arguments
        client.create_flow_run.assert_called_once_with(
            flow_id="abc123", parameters={"test": "ing"}
        )
Exemplo n.º 4
0
    def test_flow_run_task_with_flow_run_id(self, client, cloud_api):
        # verify that create_flow_run was called
        task = FlowRunTask(
            project_name="Test Project",
            flow_name="Test Flow",
            parameters={"test": "ing"},
        )

        # verify that run returns the new flow run ID
        with prefect.context(flow_run_id="test-id"):
            assert task.run() == "xyz890"

        # verify create_flow_run was called with the correct arguments
        client.create_flow_run.assert_called_once_with(
            flow_id="abc123",
            parameters={"test": "ing"},
            idempotency_key="test-id")
Exemplo n.º 5
0
    def test_flow_run_task(self, client, cloud_api):
        # verify that create_flow_run was called
        task = FlowRunTask(
            project_name="Test Project",
            flow_name="Test Flow",
            parameters={"test": "ing"},
            run_name="test-run",
        )
        # verify that run returns the new flow run ID
        assert task.run() == "xyz890"
        # verify the GraphQL query was called with the correct arguments
        query_args = list(
            client.graphql.call_args_list[0][0][0]["query"].keys())[0]
        assert "Test Project" in query_args
        assert "Test Flow" in query_args

        # verify create_flow_run was called with the correct arguments
        client.create_flow_run.assert_called_once_with(
            flow_id="abc123",
            parameters={"test": "ing"},
            idempotency_key=None,
            context=None,
            run_name="test-run",
        )
Exemplo n.º 6
0
 def test_flow_run_task_without_project_name(self, cloud_api):
     # verify that a ValueError is raised without a project name
     task = FlowRunTask(flow_name="Test Flow")
     with pytest.raises(ValueError, match="Must provide a project name."):
         task.run()
Exemplo n.º 7
0
 def test_flow_run_task_without_flow_name(self, server_api):
     # verify that a ValueError is raised without a flow name
     task = FlowRunTask()
     with pytest.raises(ValueError, match="Must provide a flow name."):
         task.run()