Skip to content

Conversation

@chemelnucfin
Copy link
Contributor

breaking up #4515

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 18, 2017
elif self.start_closed is not None:
kwargs['start_closed'] = _make_list_value_pb(self.start_closed)
else:
kwargs['start_closed'] = _make_list_value_pb([])

This comment was marked as spam.

This comment was marked as spam.


import unittest

import six

This comment was marked as spam.

self._make_one(end_open=KEY_1, end_closed=KEY_2)

def test_ctor_w_only_start_open(self):
def test_ctor_start_open_and_start_closed_empty_lists_and_end_closed(self):

This comment was marked as spam.

with self.assertRaises(ValueError):
self._make_one(start_open=KEY_1, end_open=[], end_closed=[])

def _check_unused_keys(self, krange, used_keys):

This comment was marked as spam.

'end_open')
for key_type in key_types:
if key_type not in used_keys:
self.assertFalse(krange.to_pb().HasField(key_type))

This comment was marked as spam.

This comment was marked as spam.

self.assertEqual(krange.end_closed, None)
KEY_2 = [u'key_2']
with self.assertRaises(ValueError):
self._make_one(start_open=[], start_closed=[], end_closed=KEY_1)

This comment was marked as spam.

self._make_one(start_open=[], start_closed=[], end_closed=KEY_1)

def test_ctor_w_only_start_closed(self):
def test_ctor_start_open_and_end_open_and_end_closed_empty_lists(self):

This comment was marked as spam.

self.assertIsNone(krange.start_closed)
self.assertIsNone(krange.end_open)

def test_ctor_single_key_end_open(self):

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

self.assertEqual(pb_key_type.values[0].string_value, KEY_1[0])
self._check_unused_keys(krange, used_keys)

def test_to_pb_single_key_end_open(self):

This comment was marked as spam.

"""
def __init__(self, start_open=None, start_closed=None,
end_open=None, end_closed=None):
if not any([start_open, start_closed, end_open, end_closed]):

This comment was marked as spam.

if start_open is not None and start_closed is not None:
raise ValueError("Specify one of 'start_open' / 'start_closed'.")
elif start_open is None and start_closed is None:
start_closed = []

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

raise ValueError("Must specify at least a start or end row.")

if start_open and start_closed:
if start_open is not None and start_closed is not None:

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@chemelnucfin chemelnucfin force-pushed the spanner_only_key_bugfix branch from 9954202 to 63b8948 Compare December 19, 2017 01:14
@chemelnucfin
Copy link
Contributor Author

maybe breaking this up and changing the code all at once isn't such a great idea.....

@chemelnucfin
Copy link
Contributor Author

working on it...

@chemelnucfin chemelnucfin force-pushed the spanner_only_key_bugfix branch 2 times, most recently from 762322c to ba5619c Compare December 19, 2017 07:55
@chemelnucfin chemelnucfin force-pushed the spanner_only_key_bugfix branch from ba5619c to 9283a46 Compare December 19, 2017 08:01
end_open=None, end_closed=None):
if not any([start_open, start_closed, end_open, end_closed]):
keys = (start_open, start_closed, end_open, end_closed)
if all(key is None for key in keys):

This comment was marked as spam.

if start_open is not None and start_closed is not None:
raise ValueError("Specify one of 'start_open' / 'start_closed'.")
elif start_open is None and start_closed is None:
start_closed = []

This comment was marked as spam.

kwargs['start_open'] = _make_list_value_pb(self.start_open)

if self.start_closed:
else:

This comment was marked as spam.

self._make_one()

def test_ctor_w_start_open_and_start_closed(self):
def test_ctor_start_open_and_start_closed(self):

This comment was marked as spam.

This comment was marked as spam.

with self.assertRaises(ValueError):
self._make_one(start_open=KEY_1, end_open=[], end_closed=[])

def _check_unused_keys(self, key_range, used_keys):

This comment was marked as spam.

self.assertIsNone(krange.start_open)
self.assertIsNone(krange.end_open)

def test_ctor_single_key_end_open(self):

This comment was marked as spam.

@chemelnucfin chemelnucfin force-pushed the spanner_only_key_bugfix branch 3 times, most recently from 020091d to 8d84c34 Compare December 19, 2017 17:56
@chemelnucfin
Copy link
Contributor Author

@dhermes PTAL, thanks.

raise ValueError("Must specify at least a start or end row.")
if ((start_open is None and start_closed is None)
or (start_open is not None and start_closed is not None)):
raise ValueError("Specify exactly one start key type")

This comment was marked as spam.

@chemelnucfin chemelnucfin force-pushed the spanner_only_key_bugfix branch from 8d84c34 to 4192357 Compare December 19, 2017 20:15
@chemelnucfin
Copy link
Contributor Author

no opposition, changed.

if not any([start_open, start_closed, end_open, end_closed]):
raise ValueError("Must specify at least a start or end row.")
if ((start_open is None and start_closed is None)
or (start_open is not None and start_closed is not None)):

This comment was marked as spam.

This comment was marked as spam.


KEY_1 = [u'key_1']
with self.assertRaises(ValueError):
krange = self._make_one(start_closed=KEY_1)

This comment was marked as spam.

This comment was marked as spam.

@chemelnucfin chemelnucfin force-pushed the spanner_only_key_bugfix branch from e973bd7 to a106cda Compare December 20, 2017 01:01
- Converting to "Google" docstring style
- Adding note about the "exactly one of" requirement with
  a suggestion about what to pass if the start/end is not
  important to the user
- Adding a `Raises` section to the class docstring
Also reworked the `to_pb()` tests to just create a protobuf and
just use one assertion.
@dhermes dhermes force-pushed the spanner_only_key_bugfix branch from a106cda to 88ca5bb Compare December 20, 2017 17:59
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Dec 20, 2017
Copy link
Contributor

@dhermes dhermes left a comment

Choose a reason for hiding this comment

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

LGTM

@dhermes dhermes merged commit 4d6cd26 into googleapis:master Dec 20, 2017
dhermes pushed a commit that referenced this pull request Dec 20, 2017
theacodes pushed a commit that referenced this pull request Jan 10, 2018
theacodes pushed a commit that referenced this pull request Jan 11, 2018
#4733)

Revert "Spanner: Make sure **exactly** one of `start_*`/`end_*` are passed to KeyRange (#4618)"

This reverts commit 4d6cd26.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants