#128 Tests failing in test_view.py
Closed: complete 4 years ago by jflory7. Opened 5 years ago by shraddhaag.

Summary

The failing tests in test_views.py need to be fixed.

Background

There are 6 tests failing in test_views.py with an AssertionError.

Details

Steps to reproduce:

  1. Get the local development server running and access the shell of the docker container.
  2. Run python manage.py test happinesspackets.messaging.tests.test_views

It should show an output with Traceback to the failing test. Mine looks like this.

All the tests show the same error code Assertion error. Response code expected was 200 while received was 302.

A good first step will be to reproduce the same at your own local development environment.

Outcome

All test cases in the view_tests.py must pass successfully without any errors.


Metadata Update from @jflory7:
- Issue priority set to: waiting on assignee (was: awaiting triage)
- Issue tagged with: bug, good first issue, type - quality assurance, type - summer coding

5 years ago

Metadata Update from @jflory7:
- Issue tagged with: PASSED

5 years ago

@shraddhaag This is a great task to work on. Did you want to work on this now or did you want to open it for others to work on?

@shraddhaag I was able to reproduce this too.

Also, when executing docker-compose exec web sh followed by ./t
2 more errors are shown in the output, as seen here.

Hello @shraddhaag
I'm an OutReachy Internship applicant and I'm requesting to take this on.

@jflory7 Came across this issue and thought it must be worked on :)
@simicode sure go ahead!

Thanks @shraddhaag. I'm on it!
You may assign it to me to let other contributors know there is someone on it :thumbsup:

There are 6 tests failing in test_views.py with an AssertionError.

I want to make sure I'm reading this right. The tests are failing because of a failed redirect as far as I can tell. Is this because the tests are running as an unauthenticated user, and thus unable to complete some tests successfully?

I haven't looked closely at the tests before, so I'm not 100% certain what's happening here yet.

You may assign it to me to let other contributors know there is someone on it

@simicode Thanks for your interest to work on this. Were you able to reproduce this locally in your development environment? Any ideas on how to approach this ticket?

Metadata Update from @jonatoni:
- Issue assigned to simicode

5 years ago

@simicode any update on this ticket? Can you please reply @jflory7 question regarding the approach how to fix it?

Let us know if you need help :)

Thanks for the informative comments, I got some environment errors but I'm looking to provide an update on this today.

@jflory7 @jonatoni
This issue has been reproduced in my environment.

Ran 30 tests in 13.853s FAILED (failures=6)

The AssertionError is mostly happening against temporary redirects: AssertionError: 302 != 200
Join me in investigating why.

The AssertionError is mostly happening against temporary redirects: AssertionError: 302 != 200

This is correct. I had a question about this here. It's not clear to me why this error happens. This ticket needs some investigating to figure out why this happens. :mag:

Further steps:

  1. I think we need to check whether there have been any changes in the auth API at iddev.fedorainfracloud.org. This could also cause the errors.

  2. Can we please tag the original contributor of these tests to get their comments? I could use some of their guidance to solve this.

(To Note: Those tests were part of the code when it was ported from github)

These are my thoughts, What do you think?
How would you advise us to go about this? @jflory7

I think we need to check whether there have been any changes in the auth API at iddev.fedorainfracloud.org. This could also cause the errors.

I realized there could be a mistake. iddev.fedorainfracloud.org is possibly a staging instance of the production id.fedoraproject.org site. They both use Ipsilon as far as I know, so maybe we need to point to the production Ipsilon instance. This is a guess though, I haven't looked into this too deeply.

Can we please tag the original contributor of these tests to get their comments? I could use some of their guidance to solve this.

(To Note: Those tests were part of the code when it was ported from github)

Looking closer, I think something might have broken in commit ce88a4f. A good next step is to revert back to a last known good commit and figure out where the bug entered the project.

I suggest reverting back to these points in time and then running tests again:

git checkout -b 128/test-1 -t master
git revert 73fd71488dadc28e0c8995d225b8ad845f26ad18
# re-run tests
git checkout -b 128/test-2 -t master
git revert 844d92972d1a286500d74698ad3b2fa1a8bc27a5

One or both of these two commits may work as expected. Knowing how both commits work makes this easier to pinpoint.

Thanks! Let me revert, run the tests and update you.

Hi @jflory7, I reverted back to both points as you indicated and re-run the test. Still getting Ran 30 tests in 13.853s FAILED (failures=6) as originally.
Could this AssertionError: Couldn't retrieve redirection page '/oidc/authenticate/': response code was 302 (expected 200) indicate something?
I get the same error when I want to login to the local instance of the website web_1 | [07/Mar/2019 12:36:33] "GET /oidc/authenticate/? HTTP/1.1" 302 0

@simicode @anasustic First, I realized I made a mistake in my git commands. The actual command should be git reset --hard <commit> instead of git revert. My mistakeā€¦

I don't have enough context to have a fast answer to this one. I'll try to dig up a lead for this one, but someone else might beat me to to it.

Hi @jflory7 I re-run the tests with git reset --hard <commit> bust still no go :grinning:

@anasustic @jflory7 302 Found redirect status response code indicates that the resource requested has been moved to a new URL to which it is automatically redirected to as mentioned here.

We face it because /oidc/authenticate redirects to iddev.fedorainfracloud.org/openidc/Registration.

I get the same error when I want to login to the local instance of the website web_1 | [07/Mar/2019 12:36:33] "GET /oidc/authenticate/? HTTP/1.1" 302 0

That's the reason the terminal is logging it too.

This commit was made to solve this exact issue but I suppose something else must have changed that's still causing these errors to raise.

I'm unsure as to what as of now. I'll be sure to post my findings here :)

Metadata Update from @jflory7:
- Assignee reset
- Issue tagged with: help wanted, needs info

5 years ago

Metadata Update from @jflory7:
- Custom field Requirement # adjusted to 29

4 years ago

Metadata Update from @jflory7:
- Issue untagged with: good first issue, help wanted, needs info
- Issue assigned to alishapapun
- Issue set to the milestone: Summer Coding 2019: phase 2

4 years ago

@alishapapun is in progress of migrating the existing test suite to Pytest. Part of that migration includes fixing these existing tests. I'm updating the ticket assignee accordingly!

Metadata Update from @jflory7:
- Issue close_status updated to: complete
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata