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

Fixes error introduced in commit 5dcd716 #1951

Merged
merged 1 commit into from
Dec 20, 2016
Merged

Conversation

manishtomar
Copy link
Contributor

assoc_obj was the real culprit in commit 5dcd716 which returned CLBNode with _drained_at=None all the time. (I never liked it from the beginning). This made the unit tests pass as code and test got objects with None drained_at. Fixed by switching to attr and using its assoc method which ensures the attribute exists before accepting.

assoc_obj was the real culprit which returned CLBNode with
_drained_at=None all the time. This made the unit tests pass as code
and test got objects with None drained_at. Fixed by switching to attr and using
its assoc method which ensures the attribute exists before accepting.
@manishtomar
Copy link
Contributor Author

jenkins please run integration tests

@codecov-io
Copy link

codecov-io commented Dec 14, 2016

Current coverage is 92.53% (diff: 100%)

Merging #1951 into master will increase coverage by <.01%

@@             master      #1951   diff @@
==========================================
  Files            83         83          
  Lines          7493       7500     +7   
  Methods           0          0          
  Messages          0          0          
  Branches       1019       1019          
==========================================
+ Hits           6933       6940     +7   
  Misses          463        463          
  Partials         97         97          

Powered by Codecov. Last update 0a715a7...9b356d6

@manishtomar
Copy link
Contributor Author

jenkins please run integration tests

@manishtomar
Copy link
Contributor Author

@glyph review please

@manishtomar
Copy link
Contributor Author

@glyph Please note that 5dcd716 has not been deployed due to failed integration tests.

Copy link
Contributor

@glyph glyph left a comment

Choose a reason for hiding this comment

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

Continuing the migration to attrs is definitely a good thing. You should definitely carefully consider if the mutation-rather-than-returning-a-modified-value is desirable here, but otherwise it seems fine.

However, it does make me question rather having an attribute raise DrainingUnavailable is actually a good interface here; perhaps it should be a method, or perhaps the try: suite should be capturing less code? I don't have an immediate suggestion, just that this looks like a subtle magnet for future bugs.

@@ -605,7 +604,7 @@ def test_lb_disappeared_during_feed_fetch(self):
eff = get_clb_contents()
self.assertEqual(
perform_sequence(seq, eff),
([assoc_obj(CLBNode.from_node_json(2, node21), drained_at=2.0)],
([attr.assoc(CLBNode.from_node_json(2, node21), _drained_at=2.0)],
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh. That's an interesting bug in assoc; I thought it would have behaved the same as __init__ when it came to private variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return assoc_obj(node, drained_at=extract_clb_drained_at(feed))
else:
return node
node.drained_at = extract_clb_drained_at(feed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this being changed to mutate its input rather than return a new value? What is the input being shared with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is this being changed to mutate its input rather than return a new value?

I didn't want to do call assoc with a private variable.

What is the input being shared with?

What input? node argument? Sorry, didn't understand.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the node argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as calling assoc with a private variable... that seems like a bug in attrs which this is just a workaround for (and you're not reaching across library boundaries, at least)

@manishtomar manishtomar merged commit 9f1f77c into master Dec 20, 2016
@manishtomar manishtomar deleted the no-drainedat-fix branch December 20, 2016 17:41
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.

3 participants