-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply "unify bucket and key" before "provide bucket" #28710
Apply "unify bucket and key" before "provide bucket" #28710
Conversation
395045e
to
9739f4d
Compare
b1f5d0e
to
eead6c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but to me the tests are looking quite complex because of all the branches.
5a61f84
to
322f18e
Compare
ok @o-nikolas and @feluelle i have updated these tests to move the "tokens" to individual params. it's not quite "putting the test values in the tuple", which, if i understood correctly, is what yall were thinking of (and what i more or less strenuously object to doing, myself anyway) but hopefully it's "orthodox enough" to not raise anyone's hackles (i kid) while still being relatively compact and readable. 🥳 |
def test_s3_head_object_decorated_behavior(mock_conn, has_conn, has_bucket, key_kind, expected): | ||
if has_conn == "with_conn": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making these changes @dstandish! It's very much appreciated 🙏 and is indeed what I was describing before. The only other improvement is that you can actually just make many of the params here simply booleans instead of strings. This would allow you to get rid of the string comparisons in the conditionals of the test body.
But of course feel free to do this or not :)
P.S. I tried, but unfortunately cannot, add a full suggested change for the above because the snippet includes deleted lines 927/928 and the GitHub UI does not allow that, and I didn't want to include a partial one so as to avoid confusion.
Thanks @dstandish! And this was actually exactly what I was intending in the previous CR, apologies if we miscommunicated there 🙏 |
Thanks @dstandish. I appreciate that. :) I think writing tests is not about being DRY. It much more important that they are readable and maintainable. |
Glad to see we got to common conclusions even after some initial strugles in communication :) BTW.
Yep. 100% agree. DRY is important but for tests DAMP is importanter :D :D https://enterprisecraftsmanship.com/posts/dry-damp-unit-tests |
By all means, gold plate this to your hearts content 😜 Now if we can figure out why tests failing.... Meanwhile I'm in the mountains and checked out for a few days 🌧️ |
Co-authored-by: Felix Uellendall <feluelle@users.noreply.github.com>
- resolve "no conn", "no bucket", "rel key" args before running the test
729e275
to
d696222
Compare
ok i think i have gotten the test issue fixed now... it was the result of reloading the s3 module. after that, mocks don't work. separately i had a chance to look at the change @feluelle and i reverted, in small part cus it was failing :) but mainly because... this is sort of why i objected to doing it that way. thanks |
Not to me, but okay. Instead of # full key
# no conn - no bucket - full key
(None, {"key": "s3://key_bucket/key.txt"}, ["key_bucket", "key.txt"]), you would do: param(None, {"key": "s3://key_bucket/key.txt"}, ["key_bucket", "key.txt"], id="unify-no_conn-no_bucket-full_key"), and you get more descriptive output in pytest.
Isn't this the same as with comments (we have above each line)? And comments also can be valuable. You just need to make sure to update them accordingly. |
yes absolutely it is, and this is a good reminder to remove them, which i've now done. i also rearranged things so that the truth table is built in the normal, sane way, and unify vs provide remain innermost (since those are what we are actually comparing here). now it's much easier to see that we have everything covered, and we no longer need the comments. |
Previously if user provided full key it may be overwritten by conn bucket but now we fix ordering of decorators and this won't happen.
This fix doesn't seem to break backcompat because previously you'd get call(Bucket='bucket', Key='s3://other-bucket/file.txt') which should fail anyway.
depends on #28707