studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.52k stars 267 forks source link

No tests in code #74

Closed sdague closed 7 years ago

sdague commented 7 years ago

I've started hacking on this for some features I'd really like in home-assistant. The fact that the code doesn't have any tests makes it quite easy to break by accident on new patches.

I'd be happy to start building up some tests and connect this to the travis infrastructure if there is upstream interest. Please let me know, and I'll start in on that work.

Thanks again for this great base library. Hoping to help make it even better.

natcl commented 7 years ago

Yes, that would be great !

sdague commented 7 years ago

Cool, I'll start in on that this evening if I get a chance. I'm also curious how important the single file / no dependencies is on the functional side. When I was playing with flake8 on the code the way 2/3 support is done makes it a bit sad, because unicode doesn't exist as a function in python 3. Using six for those kinds of parts would definitely make linting happier as well.

natcl commented 7 years ago

The main reason for single file/no dependencies is to make it easy to run with Pythonista on iOS or various Android python interpreters.
I agree that the unicode/p3k support could be improved...

sdague commented 7 years ago

Started working on this here - https://github.com/studioimaginaire/phue/pull/75

However, given the number of HTTP requests happening behind the scenes (like the fact that Light name is dynamic) manually mocking the request method is getting a bit wonky. It's a start, but man using requests/requests-mock would be so much simpler here. :)

sdague commented 7 years ago

I think I came up with a workable patching of HTTPConnection to make life easier there, in last patch