Skip to content
This repository was archived by the owner on Dec 5, 2020. It is now read-only.

Conversation

@sreev
Copy link
Contributor

@sreev sreev commented Oct 13, 2020

Signed-off-by: SreeV <441385+sreev@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #115 into main will increase coverage by 1.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
+ Coverage   37.07%   38.16%   +1.09%     
==========================================
  Files          21       21              
  Lines         847      862      +15     
==========================================
+ Hits          314      329      +15     
  Misses        533      533              
Impacted Files Coverage Δ
tests/test_marquez_client.py 99.18% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52b3dde...29a009a. Read the comment docs.

assert str(response['id']) is not None
assert str(response['location']) == location
assert str(response['runId']) == run_id

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind if we also add an assert that the mock_put was called only once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's redundant. but if you insist. why not, sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Member

@julienledem julienledem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!
Please see my comment inline


assert str(response['id']) is not None
assert str(response['location']) == location
assert str(response['runId']) == run_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to check that mock_put was called with the parameters you expect.
Here is an example here:
https://github.com/MarquezProject/marquez-airflow/blob/a5a72879cfa7b4a5db1bcd6b3a11fc942943405e/tests/test_marquez_dag.py#L97

you can also assert that response is mock_put.return_value since it should returning that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense in the dag as there are many calls happening. this method is directly calling only one.

return value already there few lines above:

mock_put.return_value = {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response = return value from create_job (inside return value of mock.put).
python magic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in my comment above, you need to check that mock_put was called with the parameters you expect.
You want to verify that the run_id parameter passed to create_job is actually sent to the backend.
I would assert mock_put.call_args.kwargs["runId"] == run_id (or something similar)
Doc here: https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.call_args

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Signed-off-by: SreeV <441385+sreev@users.noreply.github.com>

assert str(response['id']) is not None
assert str(response['location']) == location
assert str(response['runId']) == run_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in my comment above, you need to check that mock_put was called with the parameters you expect.
You want to verify that the run_id parameter passed to create_job is actually sent to the backend.
I would assert mock_put.call_args.kwargs["runId"] == run_id (or something similar)
Doc here: https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.call_args

Signed-off-by: SreeV <441385+sreev@users.noreply.github.com>
"runId": run_id
}

response = self.client.create_job(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small clarification here: the job create response won't contain the run ID. The optional run ID will only be used to link a newly created job version to an existing job run, but not returned to the caller. You'd want to update your test to assert runId is part if the request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Signed-off-by: SreeV <441385+sreev@users.noreply.github.com>
== run_id

assert str(response['inputs']) is not None
assert response['latestRun'] is None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latestRun wouldn't be None is this case. When a run ID is provided, the Marquez API assumes the job has a run in a RUNNING state. We'd want to make sure the contract is correct and mock out a latest run object in the response using the run ID passed to Marquez.

The main goal for adding run ID support is to allow the caller to modify a running job while linking the new job version to the existing run. As an example, you can reference the java client test we have testCreateJobWithRunId()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with the main goal.

Signed-off-by: SreeV <441385+sreev@users.noreply.github.com>
Copy link
Member

@wslulciuc wslulciuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be a few comments @julienledem made that would need to be addressed? but otherwise LGTM 👍

@sreev
Copy link
Contributor Author

sreev commented Oct 16, 2020

I think there might be a few comments @julienledem made that would need to be addressed? but otherwise LGTM 👍

Addressed.

@sreev sreev merged commit 0e60fdc into main Oct 16, 2020
@sreev sreev deleted the test-cases branch October 16, 2020 16:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants