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

Merge Shell Connector into Core #735

Closed
wants to merge 10 commits into from

Conversation

FabioRosado
Copy link
Member

Description

Since we have a PR #725 waiting for the shell connector to be merged into core I decided to take up the task to do it. @jacobtomlinson I know that you were thinking to do this yourself eventually, but perhaps you were thinking to modify some things on this connector?

I have made little changes to the connector, mostly some refactoring in order to get linting happy and merged the external functions into the connector class. Everything seems to be working ok as opsdroid works fine with this connector now.

I'm having an issue with testing the async_input method as I don't fully understand what is happening there. Also, line 49 is not being tested, but I assume that once the async_input method is tested properly this will pass.

If possible could you give me a hand testing this method in order to get Travis happy? 馃槃

Fixes #667

Status

READY | UNDER DEVELOPMENT | ON HOLD

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (Google style docstrings still need to be implemented)
  • Documentation (fix or adds documentation)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • Tox all green - but coverage is reduced to 98%
  • Opsdroid runs without any issues

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@jacobtomlinson
Copy link
Member

It looks like travis is happy but appveyor isn't. I imagine this is an issue to do with pipes on Windows. I would recommend exploring how to capture stdin with asyncio on Windows.

Also looking back through the code we seem to set up a reader and writer. However we only use the reader as we are writing using print. I expect this is probably because this code is copied from stack overflow 馃槃. You may want to remove the writing code to simplify things, that may also help with your testing.

@FabioRosado
Copy link
Member Author

Haha okay I will work on this more tomorrow and try to figure out how to solve some of these issues 馃憤

@codecov
Copy link

codecov bot commented Nov 14, 2018

Codecov Report

Merging #735 into master will decrease coverage by 0.21%.
The diff coverage is 93.1%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #735      +/-   ##
==========================================
- Coverage     100%   99.78%   -0.22%     
==========================================
  Files          27       28       +1     
  Lines        1804     1862      +58     
==========================================
+ Hits         1804     1858      +54     
- Misses          0        4       +4
Impacted Files Coverage 螖
opsdroid/connector/shell/__init__.py 93.1% <93.1%> (酶)

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update e1f004e...7e72875. Read the comment docs.

@FabioRosado
Copy link
Member Author

I've updated the stdio method by removing all the writer references, I tried to bump the coverage but I kept getting a lot of issues when trying to test this method so I am still at loss as to how to properly test it.

I get issues with readlines, then with replace, I tried to mock the readlines from asyncio.StreamReader and I guess I could move the decode('utf8').replace(...) into an helper function and then mock that as well, but that causes the with statement to be massive in the tests.

Any idea how to test this bit, because I have no idea haha

I will fix the linting issues on the next commit

@jacobtomlinson
Copy link
Member

jacobtomlinson commented Nov 14, 2018

Yeah I would just mock that stuff out, don't worry too much about a large with statement. You could always use the patch decorator if you prefer.

I wouldn't move the string cleaning stuff out, that shouldn't be causing an issue.

@FabioRosado
Copy link
Member Author

FabioRosado commented Nov 17, 2018

I'm pondering to go and just close this PR. I have been trying for the whole week to figure out how to test these two functions without any success. This last commit bumps the coverage but its nothing but a hack to do it.

With the async_input I either get an issue on the readline, or i get an issue with that return statement due to the replace() chaining

Also, this connector will never work on windows as it is. I tried to play around with it in order to make it work on windows, after long hours reading stackoverflow the solution might pass to go and use run_in_executor method, but that only the rabbit hole further as I get another exception DoNotReadFromInput with every little change i try to make

@jacobtomlinson
Copy link
Member

Perhaps we should scrap the shell connector all together and use websockets and opsdroid desktop as the default.

@jacobtomlinson
Copy link
Member

As discussed on matrix we could also move this into a separate application (called opsdroid-client or similar) and connect using websockets like opsdroid desktop does. That way we could avoid all the asyncio stdin/stdout issues we are having and implement it more simply.

@FabioRosado
Copy link
Member Author

I'm giving this bit a test (even if its buggy to sigkill opsdroid) I'm curious to see if things will okay okay-ish on windows, if they do i'll worry about the rest later.

On the testing bit, I am still failing to see how to test the return statements properly since tox keeps complaining about it.

Since this PR has caused a bit of a headache i might just update the shell connector until we decide to implement that client idea.

@FabioRosado
Copy link
Member Author

AppVeyor is calling the wrong bit of code, but yeah I guess this wont work either.

@FabioRosado FabioRosado deleted the connector-shell branch December 18, 2018 17:20
@jos3p jos3p mentioned this pull request Oct 9, 2019
10 tasks
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.

Move shell connector into core
2 participants