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

update to work with openevse 3.0.2dev #7

Merged
merged 11 commits into from
Aug 1, 2020

Conversation

a-u-s-t-i-n
Copy link
Contributor

  • protocol version 4.0.1
  • use json by default (kept the xml parser)
  • added checksum check

- protocol version 4.0.1
- use json by default (kept the xml parser)
- added checksum check
@miniconfig miniconfig mentioned this pull request Apr 28, 2020
@miniconfig
Copy link
Owner

@a-u-s-t-i-n This PR re-introduces the issue that #4 Fixed. That's not entirely surprising since there was embarrassingly no testing at all previously. I've spent a couple days cleaning up the repo and adding tests for the v1 version of the firmware that my charger is currently running, so if you'd like, you should be able to re-make your changes to the current version and make sure those tests pass (new tests for v3 would also be great!). I may try to upgrade my firmware if my hardware will support it, but that may take some time.

@a-u-s-t-i-n
Copy link
Contributor Author

No worries. I can add this into the current version. I thought about adding the tests last time but it seemed like too invasive an addition -- particularly since I couldn't test the v1 responces.

I'm trying to figure out how to run the test rig: I haven't used pytest before and I keep getting an error:

fixture 'requests_mock' not found

Do you know where requests_mock should come from?

@a-u-s-t-i-n a-u-s-t-i-n changed the title update to work with openevse 3.0.2dev WIP: update to work with openevse 3.0.2dev May 14, 2020
@miniconfig
Copy link
Owner

You should be able to use pip install requests-mock, or, if you have poetry installed, poetry install will install all of the dependencies.

@a-u-s-t-i-n a-u-s-t-i-n changed the title WIP: update to work with openevse 3.0.2dev update to work with openevse 3.0.2dev Jul 4, 2020
@a-u-s-t-i-n
Copy link
Contributor Author

Thanks -- I didn't think to consider pip.

I've added in some tests: I didn't get every test you had, but I think there is enough there to cover the basics. Let me know if you disagree...

I think it is ready to merge.

openevsewifi/__init__.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
if response is None:
response = re.search('\\>\\>\\$(.+)\\<p>', content.text)
return response.group(1).split()
return self._parseResult(content.text)
Copy link
Owner

Choose a reason for hiding this comment

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

The type hint on line 85 indicates that _send_command should return a list of strings, but your change is violating that contract - it now returns a string if the parser is XML, but if it is using the JSON parser and runs into an error, it could return None.

openevsewifi/__init__.py Outdated Show resolved Hide resolved
@ausil
Copy link

ausil commented Jul 13, 2020

trying to apply this PR locally to test it will nt apply to the current development branch

@miniconfig
Copy link
Owner

trying to apply this PR locally to test it will nt apply to the current development branch

Can you be a little more specific as to the commands you're running and the errors you're seeing?

@ausil
Copy link

ausil commented Jul 13, 2020

I grabbed the raw patch and applied with git am 7.patch it fails to apply because setup.py has been removed from the repo.

@ausil
Copy link

ausil commented Jul 13, 2020

to be more specific in the error

[dennis@anubis python-openevse-wifi (master)]$ git am 7.patch
Applying: update to work with openevse 3.0.2dev
error: patch failed: openevsewifi/init.py:2
error: openevsewifi/init.py: patch does not apply
error: setup.py: does not exist in index

@miniconfig
Copy link
Owner

@ausil , it's actually failing for multiple reasons. Can you just check out the branch and merge into a test branch?

Starting at master:

git checkout -b pr7
git pull https://github.com/a-u-s-t-i-n/python-openevse-wifi.git master
git checkout test-pr-7-merge
git merge --no-ff pr7

@a-u-s-t-i-n
Copy link
Contributor Author

Let me know if there is anything else -- thanks for working with me to get it into shape.

@a-u-s-t-i-n
Copy link
Contributor Author

a-u-s-t-i-n commented Jul 15, 2020

@ausil I'm not able to replicate the patch failure. In particular, the following works for me (in a new directory):

git clone https://github.com/miniconfig/python-openevse-wifi.git
cd python-openevse-wifi
git pull https://github.com/a-u-s-t-i-n/python-openevse-wifi.git

When I try to follow your commands, I get:

error: pathspec 'test-pr-7-merge' did not match any file(s) known to git

after the checkout of that branch.

I also don't understand the point of those last two commands: does the --no-ff merge do something useful or necessary?

@a-u-s-t-i-n
Copy link
Contributor Author

I put the "import setup" back in. The poetry tests in github failed when I removed it and passed when it was back. I didn't set these up -- I guess they came for free when I forked from miniconfig.

@miniconfig
Copy link
Owner

I put the "import setup" back in. The poetry tests in github failed when I removed it and passed when it was back. I didn't set these up -- I guess they came for free when I forked from miniconfig.

This was probably a lack of clarity on my part - you don't need to delete the import line, you need to delete the entire file. If you delete the entire file, poetry won't try to use it, it will install using the pyproject.toml file. If setup.py is there and broken, however, it seems like it tries to use it and fails. I think if you fix that, this looks good to go.

@a-u-s-t-i-n
Copy link
Contributor Author

This was probably a lack of clarity on my part - you don't need to delete the import line, you need to delete the entire file. If you delete the entire file, poetry won't try to use it, it will install using the pyproject.toml file. If setup.py is there and broken, however, it seems like it tries to use it and fails. I think if you fix that, this looks good to go.

No worries. setup.py is gone, and I was able to install locally with poetry. Thanks again!

@miniconfig miniconfig merged commit 0cb3c6f into miniconfig:master Aug 1, 2020
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