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

Add tests for the code #43

Closed
theSage21 opened this issue Jan 19, 2019 · 14 comments
Closed

Add tests for the code #43

theSage21 opened this issue Jan 19, 2019 · 14 comments
Labels
enhancement New feature or request

Comments

@theSage21
Copy link
Member

As found out in another discussion the project is now big enough that simply reading the code during review does not ensure that it will run.

For starters a simple test file is needed which can run the server and make sure it does not crash. Later on we can add more tests.

@theSage21 theSage21 added the enhancement New feature or request label Jan 19, 2019
@theSage21
Copy link
Member Author

Some auto testing providers I know of:

The project needs to be integrated with them.

@shivankgtm
Copy link
Contributor

@kirtibajaj I guess as you are managing this product, so it should be done by you.

@shivankgtm
Copy link
Contributor

do we still need it?
i can work on it.

@theSage21
Copy link
Member Author

theSage21 commented Jan 26, 2019 via email

@shivankgtm
Copy link
Contributor

ok then, I am on it. do I need to keep something in mind for the approach ? as i don't have any experience with travis or circle, just little bit of unit tests.

@theSage21
Copy link
Member Author

For now I think simply testing if the server runs is enough. Later on as need increases we can improve testing standards.

@theSage21
Copy link
Member Author

that will catch all syntax errors and so on.

@shivankgtm
Copy link
Contributor

while writing the tests i faced a error, i tried google too but didn't understand it. else it test for other two functions in server.py are running OK.

def test_file_upload(self):
        #assert app.post('/check/1').status_code == 200
        print(app.post('/check/1').status_code)

and this give me this error.

ERROR: test_file_upload (test_pyjudge.TestPyJudge)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shivank98/Desktop/PyJudge/PyJudge/test_pyjudge.py", line 16, in test_file_upload
    print(app.post('/check/1').status_code)
  File "/home/shivank98/anaconda3/lib/python3.7/site-packages/webtest/app.py", line 382, in post
    content_type=content_type)
  File "/home/shivank98/anaconda3/lib/python3.7/site-packages/webtest/app.py", line 758, in _gen_request
    expect_errors=expect_errors)
  File "/home/shivank98/anaconda3/lib/python3.7/site-packages/webtest/app.py", line 654, in do_request
    self._check_status(status, res)
  File "/home/shivank98/anaconda3/lib/python3.7/site-packages/webtest/app.py", line 686, in _check_status
    res)
webtest.app.AppError: Bad response: 500 Internal Server Error (not 200 OK or 3xx redirect for http://localhost/check/1)

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html>
        <head>
            <title>Error: 500 Internal Server Error</title>
            <style type="text/css">
              html {background-color: #eee; font-family: sans;}
              body {background-color: #fff; border: 1px solid #ddd;
                    padding: 15px; margin: 15px;}
              pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
            </style>
        </head>
        <body>
            <h1>Error: 500 Internal Server Error</h1>
            <p>Sorry, the requested URL <tt>&#039;http://localhost:80/check/1&#039;</tt>
               caused an error:</p>
            <pre>Internal Server Error</pre>
        </body>
    </html>

@theSage21
Copy link
Member Author

can we please stop having code in comments. Just submit a PR and we can discuss things there.

@shivankgtm
Copy link
Contributor

sure sure, my bad

@shivankgtm
Copy link
Contributor

@theSage21 i am back. is this issue still on ?
or if i can remember you added tests yourself?

@theSage21
Copy link
Member Author

This is still on. I haven't written any code I can remember for this

@cquark7
Copy link
Contributor

cquark7 commented Mar 30, 2019

Hey @theSage21, I think it would be better to use pytest as our testing framework. What do you think?

@theSage21
Copy link
Member Author

#68 is already doing that I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants