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

tests.py - write some tests #5

Open
Treblesteph opened this issue Feb 19, 2018 · 2 comments
Open

tests.py - write some tests #5

Treblesteph opened this issue Feb 19, 2018 · 2 comments
Assignees

Comments

@Treblesteph
Copy link
Collaborator

I want to add tests for all functions in tasks.py, and maybe for those in views.py too... but then I remembered that when I was trying to get the demo up and running, I ran into a problem with the file handle. I didn't completely understand the whole issue, but it seemed to be quite hard to debug, so might be worth writing a test to help if a similar thing were to happen to someone else.

@madprime, what do you think?

@Treblesteph Treblesteph self-assigned this Feb 19, 2018
@Treblesteph
Copy link
Collaborator Author

Treblesteph commented Feb 19, 2018

pasted from slack discussion on this issue:

this wasn't simple to debug. s3 was throwing an error, possibly due to not getting content from your filehandle. I think it wasn't getting content from the filehandle because you had read the whole thing and printed it to console with handle_uploaded_file. if you comment out calling that, it works.

to be clear, the bug today was pretty hard, I'm glad I took some time to look at it for you. In case it helps, here's what I did...

I discovered S3 was erroring and did print(req2.content) to try to get an error message. Then I pasted that into google. I found a lot of complaints about S3 rejections due to missing content-length headers. (In the HTTP "headers" accompany requests and responses – in this case for the PUT.)

Then I went on the wrong track for a while wondering if the header was missing in the PUT that requests was making due to some version difference, tried running this code in python3 (which raises all sorts of issues) updating random libraries (issues pile up). That was all the wrong track.

Then I think I went back to reading internet comments, and I maybe saw one complaining that requests doesn't send content-length for empty content? It might not have said exactly that. Somehow I realized, "oh no, maybe the content is empty because it's been read and printed already" and that was the problem.

@madprime
Copy link
Member

madprime commented Feb 19, 2018 via email

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

No branches or pull requests

2 participants