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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The DB API Binary function accepts bytes data #630

Merged
merged 8 commits into from Apr 27, 2021
Merged

Conversation

@jimfulton
Copy link
Contributor

@jimfulton jimfulton commented Apr 26, 2021

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #628 馃

jimfulton added 2 commits Apr 27, 2021
Because we don't want to accidentally create a giant bytes.
if isinstance(data, int):
# This is not the conversion we're looking for, because it
# will simply create a bytes object of the given size.
raise TypeError("cannot convert 'decimal.Decimal' object to binary")
Copy link
Contributor

@tswast tswast Apr 27, 2021

Choose a reason for hiding this comment

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

isinstance is checking for int, but the error says decimal.Decimal

Loading

Copy link
Contributor Author

@jimfulton jimfulton Apr 27, 2021

Choose a reason for hiding this comment

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

Oops. Thanks.

Loading

Copy link
Contributor Author

@jimfulton jimfulton Apr 27, 2021

Choose a reason for hiding this comment

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

Done

Loading

@@ -13,6 +13,7 @@
# limitations under the License.

import datetime
import pytest
Copy link
Contributor

@tswast tswast Apr 27, 2021

Choose a reason for hiding this comment

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

Nit: We usually put pytest in the second grouping of imports rather than with the built-ins. We do try to follow PEP-8 advice.

Imports should be grouped in the following order:

  1. Standard library imports.
  2. Related third party imports.
  3. Local application/library specific imports.

You should put a blank line between each group of imports.

Loading

Copy link
Contributor Author

@jimfulton jimfulton Apr 27, 2021

Choose a reason for hiding this comment

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

Done

Loading


self.assertEqual(types.Binary(C()), b"Google")

for bad in 42, 42.0, None:
Copy link
Contributor

@tswast tswast Apr 27, 2021

Choose a reason for hiding this comment

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

I'd expect the tests for "bad inputs" to be in a separate test function.

Ideally both of these (good inputs, bad inputs) would be parameterized in pytest-style tests. I think we can actually mix those in to the same file, so we can do that without refactoring everything, especially since these tests don't require any of the setup from the unit test class.

Loading

Copy link
Contributor Author

@jimfulton jimfulton Apr 27, 2021

Choose a reason for hiding this comment

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

done

Loading

@jimfulton jimfulton marked this pull request as ready for review Apr 27, 2021
@jimfulton jimfulton requested a review from as a code owner Apr 27, 2021
@jimfulton jimfulton requested review from stephaniewang526 and removed request for Apr 27, 2021
tswast
tswast approved these changes Apr 27, 2021
@tswast tswast merged commit 4396e70 into master Apr 27, 2021
10 checks passed
Loading
@tswast tswast deleted the riversnake-fix-628 branch Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants