IDEMSInternational / molo-iogt

IoGT Frontend Site for Molo
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Running the current site using Python 2.7 #2

Closed isedwards closed 4 years ago

isedwards commented 4 years ago

@nathanbaleeta, @michaelzhang608

Using the master branch:

Can you tell me about your development setup? Are you using Python on Windows or on Linux etc.

michaelzhang608 commented 4 years ago

@isedwards ok, working on it! (I'm going to use the virtualenv Python package on macOS Catalina)

michaelzhang608 commented 4 years ago

@isedwards I got the master branch successfully running on Python 2.7 locally, however, I had to run pip install 'django-appconf==1.0.3' --force-reinstall to downgrade the django-appconf version to work with Python 2.7.

The site works as expected when I run it. I wasn't able to manually run into any problems.

This is my output after running py.test (I'm not sure; is 75% cover good enough or not?):

---------- coverage: platform darwin, python 2.7.16-final-0 ----------
Name                                                     Stmts   Miss  Cover
----------------------------------------------------------------------------
iogt/__init__.py                                             0      0   100%
iogt/admin.py                                                3      1    67%
iogt/celery.py                                               8      8     0%
iogt/middleware.py                                          85      3    96%
iogt/migrations/0001_initial.py                              5      5     0%
iogt/migrations/0002_create_importers_group.py              11     11     0%
iogt/migrations/0003_convert_recomended_articles.py         34     34     0%
iogt/migrations/0004_create_me_expert.py                    51     51     0%
iogt/migrations/0005_remove_reaction_question_index.py      11     11     0%
iogt/migrations/__init__.py                                  0      0   100%
iogt/processors.py                                           3      0   100%
iogt/settings/__init__.py                                    1      0   100%
iogt/settings/base.py                                      114      7    94%
iogt/settings/dev.py                                         9      0   100%
iogt/settings/docker.py                                     30     30     0%
iogt/settings/production.py                                 17     17     0%
iogt/templatetags/__init__.py                                0      0   100%
iogt/templatetags/pagination.py                             18      0   100%
iogt/tests/__init__.py                                       0      0   100%
iogt/tests/test_middleware.py                              144      0   100%
iogt/tests/test_pagination.py                               85      0   100%
iogt/tests/test_views.py                                    52      0   100%
iogt/urls.py                                                24      5    79%
iogt/views.py                                               25      0   100%
iogt/wsgi.py                                                 4      4     0%
----------------------------------------------------------------------------
TOTAL                                                      734    187    75%

====== 23 passed, 201809 warnings in 200.38 seconds ====
isedwards commented 4 years ago

I've not really looked into the code yet, or looked at the commit history, but there doesn't seem to be that much here in terms of custom Python code. There are also very few migrations.

  1. The relatively large number of commits may be due to work on the language translation files in /locale, there's also some work on custom templates and CSS. I've added #4 to investigate this.
  2. Issue #3 investigates whether the project's dependencies support Python 3
  3. The 2to3 tool can show changes that are required to this codebase (#5)
  4. When we complete the upgrade we should make some recommendations, including whether we should work on increasing the test coverage. Recommendations should be recorded in #1.
nathanbaleeta commented 4 years ago

I'm running on Linux and the site works as expected. I got 73% coverage when I ran the tests.

isedwards commented 4 years ago

Could you paste the output just so that we have a record of the difference?

isedwards commented 4 years ago

From the work in #7, it looks like the code is already Python 3 ready... the problem instead is that Python 2 is being used in production along with old version of Django and Wagtail that are no longer supported.

In a different virtualenv (using Python 3), could you both test the master branch (either before or after the changes made by 2to3 - I don't think it matters) and paste the resutls of the automated tests here?

michaelzhang608 commented 4 years ago

These are my test results when running on Python 3 (exactly the same results as when I ran on Python 2):

---------- coverage: platform darwin, python 3.6.4-final-0 -----------
Name                                                     Stmts   Miss  Cover
----------------------------------------------------------------------------
iogt/__init__.py                                             0      0   100%
iogt/admin.py                                                3      1    67%
iogt/celery.py                                               8      8     0%
iogt/middleware.py                                          85      3    96%
iogt/migrations/0001_initial.py                              5      5     0%
iogt/migrations/0002_create_importers_group.py              11     11     0%
iogt/migrations/0003_convert_recomended_articles.py         34     34     0%
iogt/migrations/0004_create_me_expert.py                    51     51     0%
iogt/migrations/0005_remove_reaction_question_index.py      11     11     0%
iogt/migrations/__init__.py                                  0      0   100%
iogt/processors.py                                           3      0   100%
iogt/settings/__init__.py                                    1      0   100%
iogt/settings/base.py                                      114      7    94%
iogt/settings/dev.py                                         9      0   100%
iogt/settings/docker.py                                     30     30     0%
iogt/settings/production.py                                 17     17     0%
iogt/templatetags/__init__.py                                0      0   100%
iogt/templatetags/pagination.py                             18      0   100%
iogt/tests/__init__.py                                       0      0   100%
iogt/tests/test_middleware.py                              144      0   100%
iogt/tests/test_pagination.py                               85      0   100%
iogt/tests/test_views.py                                    52      0   100%
iogt/urls.py                                                24      5    79%
iogt/views.py                                               25      0   100%
iogt/wsgi.py                                                 4      4     0%
----------------------------------------------------------------------------
TOTAL                                                      734    187    75%

================================================ 23 passed, 201810 warnings in 153.24s (0:02:33)
nathanbaleeta commented 4 years ago

Could you paste the output just so that we have a record of the difference?

2to3

isedwards commented 4 years ago

@nathanbaleeta - I didn't realise that you had failing tests (as well as the lower test coverage). Could you run pytest with -rf to get it to print a list of failed tests at the end?

nathanbaleeta commented 4 years ago

@nathanbaleeta - I didn't realise that you had failing tests (as well as the lower test coverage). Could you run pytest with -rf to get it to print a list of failed tests at the end?

pytest

isedwards commented 4 years ago

@nathanbaleeta - before you start work on a new branch, could you have a look at why your tests above are failing?

Let us know if there's anything we can do to help.

nathanbaleeta commented 4 years ago

The failing tests are both from the class TestFaceBookPixelHistoryCounter and specifically methods test_more_that_3_page_views and test_less_that_3_page_views on lines 227 and 241.

Both failing tests are related to Facebook Pixel, which is basically code you place in your website to help trigger cookies to track users as they interact with your website and your Facebook ads.

The tests attempt to check if the no script html tag exists. Below is a snapshot for further detail:

FAILED

@isedwards could you kindly share your opinion on this.

isedwards commented 4 years ago

The reason that Michael's tests passed is because he was testing the master branch (as originally intended).

The Facebook tracking tests above fail because the corresponding middleware has been disabled on the develop branch. I've fixed the tests here, but there are so many warnings generated during the tests that the Travis build terminates early, so it still needs more work.