Use base aws classes in Amazon ECS Operators/Sensors/Triggers#36393
Use base aws classes in Amazon ECS Operators/Sensors/Triggers#36393potiuk merged 5 commits intoapache:mainfrom
Conversation
Taragolis
left a comment
There was a problem hiding this comment.
Unsure how to get tests passing for test_hook_and_client in tests/providers/amazon/aws/operators/test_ecs.py, because it seems like it should just work 🤷
The better is rewrite, because in this case it mock different object. You need to mock airflow.providers.amazon.aws.operators.ecs.EcsBaseOperator.aws_hook_class however it would not work because it would fail on subclass check
You could split it by two test in first just check that expected argument are passed into the hook constructor, something similar to the
airflow/tests/providers/amazon/aws/operators/test_athena.py
Lines 80 to 101 in 5626590
And second test just mock hook property and check and check client property
|
@Taragolis thank you for the review -- all but mocking the hook property and client property should be all set. Pretty unsure how to best do that? Should I just test that the hook was not called and keep the client portion of the test the same? |
|
It could be something like that. with mock.patch.object(EcsBaseOperator, "hook", new_callable=mock.PropertyMock) as m:
mocked_hook = mock.MagicMock(name="FakeHook")
mocked_client = mock.MagicMock(name="FakeBoto3Client")
mocked_hook.conn = mocked_client
m.return_value = mocked_hook
assert op.client == mocked_client
m.assert_called_once() |
|
And after that you could remove |
|
Thank you for the example! |
|
Need to fix Static Checks:
You could have a look what failed in Tests / Static checks (pull_request) logs |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Similar to #35133 (relates to #35278)
Unsure how to get tests passing for
test_hook_and_clientintests/providers/amazon/aws/operators/test_ecs.py, because it seems like it should just work 🤷