arvind-iyer / logan

Use log files to trigger events or perform functional testing
MIT License
0 stars 1 forks source link

Pytest coverage #2

Open arvind-iyer opened 4 years ago

arvind-iyer commented 4 years ago

Need to write pytest test cases to cover all the required functionality

AminuBishir commented 4 years ago

Hello Arvind I'll like to contribute on this issue, though I can see you've already assigned it to yourself. If you're not yet done with it, kindly let me know about the "required functionalities' to be covered. Thanks.

arvind-iyer commented 4 years ago

Thanks for showing interest @AminuBishir ! This project is still at an infancy stage and I have not documented or completed all basic functionality yet. However, if you're willing to help I'm really happy to accept it. Barely any documentation has been written so far so I'm sorry about that, feel free to request for any clarifications.

Some things that need tests at high priority are:

I will write a helper script/function that will process a text log file and exit at the EOF instead of waiting endlessly for new lines. After that, it would be easier to test for the fail conditions in various situations as well.

AminuBishir commented 4 years ago

Thank you Arvind. I can see you've added the requirements in README. The clarification that I need now how to do with the usage, like what code snippet can one use to run a log on a particular file. Thanks.

arvind-iyer commented 4 years ago

Again I'm sorry for the poor documentation, I am still working on it. I use this file to run the module against plain text file, which i call 'test.log' here. It is just a simple text file with contents like this

2019-12-02 12:53:31,908 - root - DEBUG - Initializing program
2019-12-02 12:54:13,108 - root - DEBUG - Ready for execution
2019-12-02 12:54:32,145 - root - DEBUG - Waiting for input...
2019-12-02 12:54:59,800 - root - DEBUG - Received signal : START
2019-12-02 12:55:08,467 - root - DEBUG - Starting execution of code
2019-12-02 12:56:09,200 - root - DEBUG - Created sub-process for event
2019-12-02 12:56:44,573 - root - DEBUG - Execution completed in: 3.00235 seconds
2019-12-02 12:57:12,651 - root - DEBUG - Returning with success code
2019-12-02 12:57:29,993 - root - DEBUG - Ready for execution
2019-12-02 12:57:43,864 - root - DEBUG - Waiting for input...

Try creating a file containing the above and save it as 'test.log', and run this script from the same folder. https://github.com/arvind-iyer/logan/blob/master/test/test.py

AminuBishir commented 4 years ago

OK, sur I'll Thanks for the clarification.

On Mon, Dec 2, 2019, 8:38 AM Arvind Iyer notifications@github.com wrote:

Again I'm sorry for the poor documentation, I am still working on it. I use this file to run the module against plain text file, which i call 'test.log' here. It is just a simple text file with contents like this

2019-12-02 12:53:31,908 - root - DEBUG - Initializing program 2019-12-02 12:54:13,108 - root - DEBUG - Ready for execution 2019-12-02 12:54:32,145 - root - DEBUG - Waiting for input... 2019-12-02 12:54:59,800 - root - DEBUG - Received signal : START 2019-12-02 12:55:08,467 - root - DEBUG - Starting execution of code 2019-12-02 12:56:09,200 - root - DEBUG - Created sub-process for event 2019-12-02 12:56:44,573 - root - DEBUG - Execution completed in: 3.00235 seconds 2019-12-02 12:57:12,651 - root - DEBUG - Returning with success code 2019-12-02 12:57:29,993 - root - DEBUG - Ready for execution 2019-12-02 12:57:43,864 - root - DEBUG - Waiting for input...

Try creating a file containing the above and save it as 'test.log', and run this script from the same folder. https://github.com/arvind-iyer/logan/blob/master/test/test.py

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arvind-iyer/logan/issues/2?email_source=notifications&email_token=AD7YSQVG5BEYSCO2YJVKL4DQWS3QTA5CNFSM4JQMZDAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFSREKY#issuecomment-560271915, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7YSQSS3WMD4F5PGFMUJMDQWS3QTANCNFSM4JQMZDAA .

AminuBishir commented 4 years ago

Hello arvind, thank for the assignment. Please can create requirement.txt so that I can install all the required modules? Because it seems there some modules that, even though I installed them, they still satisfy the project requirement. And that shmodule seams to be only useful on linux os NOT windows and when I try installing the windows version of the sh( pbs) I got the following error: Traceback (most recent call last):

File "test.py", line 1, in <module>
    from logan import LogEvent, attach_events
  File "D:\path-to-project\logan\src\logan\logan.py", line 1, in <module>
    from pbs import tail
  File "<frozen importlib._bootstrap>", line 1019, in _handle_fromlist
  File "D:\path-to-project\logan\LOGAN-~1\lib\site-packages\pbs.py", line 575, in __getattr__
    return self.env[name]
  File "D:\path-to-project\logan\LOGAN-~1\lib\site-packages\pbs.py", line 527, in __missing__
    return Command._create(k)
  File "D:\path-to-project\logan\LOGAN-~1\lib\site-packages\pbs.py", line 265, in _create
    if not path: raise CommandNotFound(program)
pbs.CommandNotFound: __path__
arvind-iyer commented 4 years ago

Ah nice catch, apparently it works only for unix shells, I guess I need to switch from the sh module to pygtail which I hope has better support for usage on Windows.