Skip to content
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

Allow using '@' in object (key) names #204

Closed
wants to merge 3 commits into from

Conversation

dkasyanov
Copy link

@dkasyanov dkasyanov commented Jun 26, 2018

Related to the #94 issue.

Keys (objects) in AWS S2 may contain multiple '@'.
So it may be more than 2 '@' in the URI.

P.S. Bucket names can contain only lowercase letters, numbers, and hyphens.

Copy link
Collaborator

@mpenkov mpenkov left a comment

Choose a reason for hiding this comment

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

Thank you for the pull request! In general, it looks good.

Could you please add some unit tests for the new functionality?

@dkasyanov
Copy link
Author

Sure, I'll add them today.

@dkasyanov dkasyanov changed the title Allow using '@' in bucket and object names Allow using '@' in object (key) names Jun 26, 2018
@dkasyanov
Copy link
Author

@mpenkov I've added tests.
Checked that bucket name cannot contain '@'. Such test was added also.

Copy link
Collaborator

@mpenkov mpenkov left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for adding test code. Could you please split the code into new test cases? Looking at your changes, I see 3 separate test cases:

  1. test_allows_atmark_in_key (names for example only)
  2. test_allows_atmark_in_key_and_credentials
  3. test_invalid_atmark

We don't want a single test testing too many things, because if such a test fails, it can hide multiple failures. Besides, if it tests multiple things it's not really a unit test.

@@ -83,7 +83,28 @@ def test_s3_uri(self):
self.assertEqual(parsed_uri.access_id, "accessid")
self.assertEqual(parsed_uri.access_secret, "access/secret")

# incorrect uri - only two '@' in uri are allowed
# correct uri, contains credentials and '@' in object name
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a separate test.

self.assertEqual(parsed_uri.access_secret, "access/secret")

# correct uri, contains credentials, host, port and '@' in object name
parsed_uri = smart_open_lib._parse_uri("s3://accessid:access/secret@hostname:1234@mybucket/dir/my@ke@y")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a separate test.

self.assertEqual(parsed_uri.host, "hostname")
self.assertEqual(parsed_uri.port, 1234)

# incorrect uri - bucket can't contain '@'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a separate test.

@menshikh-iv
Copy link
Contributor

menshikh-iv commented Jul 31, 2018

ping @dkasyanov, are you planning to finish PR?

@mpenkov
Copy link
Collaborator

mpenkov commented Aug 29, 2018

@menshikh-iv We can probably merge this and clean up the tests as a separate ticket.

My main issue was that each of the new unit tests tests multiple things, which is bad unit testing practice.

Alternatively, I can finish this PR myself. Let me know which you prefer.

@menshikh-iv
Copy link
Contributor

@mpenkov it will be nice if you finish PR yourself

@menshikh-iv
Copy link
Contributor

Continued in #224

@menshikh-iv menshikh-iv closed this Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants