Repository: ludrao/django-tellme (language: python)

Issue:
Run tests on commit
Noticed my PR wasn't running tests.  Can we set up automated CI - github actions or something?  Would make contributions easier


Discussion / hints:
A previous contribution added tox to do the testing. But it has not run in a long time. I just tried and there are quite a few things to fix. Also probably worth removing old configuration?
If you are up to it go ahead :) Would could then add a github action to run the tox tests.
Would you mind making me a collaborator?  It would be easier to fix iteratively against actions.  Otherwise I will have to create a vagrant box for it
Actually I can make that work in a fork
Do you want to maintain backwards compatibility so far?  Or could we perhaps drop to django 3.0+?
Sorry I am not super responsive. Yes I was thinking that maybe I should give you permission directly. As I mentioned before I spent very little time on this project in the past years and you are much more proficient than I am.
That being said I had not played with github action since their creation and I am eager to check of that works so I can set that up.
@ludrao Github actions are new to me as well.  I've tinkered with it - https://github.com/thenewguy/django-tellme/actions/runs/549424585 - This builds the fronted, shuffles the frontend files to the backend, builds and tests the backend, saves both artifacts as assets.  Concept is working - just needs some minor tweaks to work with the test matrix.  I think it is 49 test combinations for the numbers of pythons and django releases this project currently supports
Great @thenewguy !
Just did my first action to publish releases, it works well. (though it is pretty simple :) )
As for you other question I guess we could reduce the support to less combinations of python and django

Fix patch:
diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml
new file mode 100644
index 0000000..69538ae
--- /dev/null
+++ b/.github/workflows/tox.yml
@@ -0,0 +1,94 @@
+name: Tox
+
+on: [push]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Setup Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: '3.x'
+      - name: Install Tox and any other packages
+        run: python -m pip install tox tox-gh-actions
+      - name: Display file tree
+        run: ls -laR tellme
+      - name: Build sdist
+        run: python -m tox -vv --sdistonly
+      - name: Archive sdist
+        uses: actions/upload-artifact@v2
+        with:
+          name: sdist
+          retention-days: 5
+          path: ~/.tox/distshare/*
+
+  test:
+    needs: build
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        python-version: [3.6,3.7,3.8,3.9]
+        django: [111,22,30,31]
+    steps:
+      - uses: actions/checkout@v2
+      - name: Setup Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      # Remove tellme source folder so we operate on the installed sdist
+      - name: Remove source folder
+        run: rm -Rf tellme
+      - name: Install Tox and any other packages
+        run: python -m pip install tox tox-gh-actions
+      - name: Download sdist
+        uses: actions/download-artifact@v2
+        with:
+          name: sdist
+          path: ~/.toxsdistsrc/
+      - name: Display structure of downloaded files
+        run: ls -aR ~/.toxsdistsrc/
+      - name: Run Tox
+        # Run tox using the version of Python in `PATH`
+        run: python -m tox -vv
+        env:
+          DJANGO: ${{ matrix.django }}
+
+  prerelease:
+    if: contains(github.event.head_commit.message, '[prerelease]')
+    needs: test
+    runs-on: ubuntu-latest
+    steps:
+      - name: Download sdist
+        uses: actions/download-artifact@v2
+        with:
+          name: sdist
+          path: ~/.toxsdistsrc/
+      - name: Display structure of downloaded files
+        run: ls -aR ~/.toxsdistsrc/
+      - name: Rename file
+        run: mv ~/.toxsdistsrc/django-tellme-*.zip /tmp/django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
+      - name: Display tmp files
+        run: ls /tmp
+      - name: Create Release
+        id: create_release
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: pre-${{ github.run_number }}-${{ github.sha }}
+          release_name: Pre-release ${{ github.run_number }}
+          draft: false
+          prerelease: true
+      - name: Upload Release Asset
+        id: upload-release-asset 
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
+          asset_path: /tmp/django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
+          asset_name: django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
+          asset_content_type: application/zip
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..2e0359b
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,36 @@
+import os
+from setuptools import setup
+
+with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
+    README = readme.read()
+
+# allow setup.py to be run from any path
+os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
+
+setup(
+    name='django-tellme',
+    version='0.6.7',
+    packages=['tellme'],
+    include_package_data=True,
+    license='BSD License',
+    description='A simple Django app that enables user feedback.',
+    long_description=README,
+    url='https://github.com/ludrao/django-tellme',
+    author='Ludrao',
+    author_email='ludrao@ludrao.net',
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Environment :: Web Environment',
+        'Framework :: Django',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: BSD License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: 3.5',
+        'Topic :: Internet :: WWW/HTTP',
+        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+    ],
+)
\ No newline at end of file
diff --git a/tox.ini b/tox.ini
index 4d9cbc2..8983d00 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,30 +2,54 @@
 addopts=--tb=short
 
 [tox]
+requires = tox-gh-actions
+
+toxworkdir = {homedir}/.toxworkdir
+sdistsrc = {homedir}/.toxsdistsrc/*
+
 envlist =
-       {py27,py34,py35}-django18,
-       {py27,py34,py35}-django19,
-       {py27,py34,py35}-django110,
-       {py27,py34,py35,py36}-django111,
-       {py34,py35,py36}-django20,
-       {py35,py36}-djangomaster,
+       py36-django{111,22,30,31}
+       py37-django{111,22,30,31}
+       py38-django{22,30,31}
+       py39-django{22,30,31,master}
        lint
-isolated_build = True
+
+[gh-actions]
+python =
+    3.6: py36
+    3.7: py37
+    3.8: py38
+    3.9: py39
+
+[gh-actions:env]
+DJANGO =
+    111: django111
+    22: django22
+    30: django30
+    31: django31
+    master: djangomaster
 
 [testenv]
 commands = ./runtests.py
+
+skip_missing_interpreters=true
+basepython =
+    py39: python3.9
+    py38: python3.8
+    py37: python3.7
+    py36: python3.6
+
 deps =
         -rrequirements-tests.txt
         Pillow
-        django18: Django>=1.8,<1.9
-        django19: Django>=1.9,<1.11
-        django110: Django>=1.10,<1.11
         django111: Django>=1.11,<2.0
-        django20: Django>=2.0,<2.1
+        django22: Django>=2.2,<2.3
+        django30: Django>=3.0,<3.1
+        django31: Django>=3.1,<3.2
         djangomaster: https://github.com/django/django/archive/master.tar.gz
 
 [testenv:lint]
 deps = 
     -rrequirements.txt
     prospector
-commands = prospector faker_cloud -0
+commands = prospector faker_cloud -0
\ No newline at end of file


Test patch:
diff --git a/runtests.py b/runtests.py
index f15ec3c..387712a 100755
--- a/runtests.py
+++ b/runtests.py
@@ -16,7 +16,7 @@ def main():
     if len(sys.argv) == 1:
         django.setup()
         TestRunner = get_runner(settings)
-        test_runner = TestRunner()
+        test_runner = TestRunner(verbosity=2)
         failures = test_runner.run_tests(["tellme.tests"])
         sys.exit(bool(failures))
     main()
diff --git a/tellme/tests/test_models.py b/tellme/tests/test_models.py
index 1c77374..b0e5fe7 100644
--- a/tellme/tests/test_models.py
+++ b/tellme/tests/test_models.py
@@ -3,9 +3,14 @@
 from tellme.models import Feedback
 from tellme.tests.factories import FeedbackFactory
 
+try:
+    from django.core.urlresolvers import reverse
+except ImportError:
+    from django.urls import reverse
+
 
 class FeedbackScreenshotMethodsTest(TestCase):
-    @mock.patch('tellme.models.reverse')
+    @mock.patch('tellme.models.reverse', wraps=reverse)
     def test_get_screenshot_url(self, mocked_reverse):
         feedback = FeedbackFactory()
         url = feedback.get_screenshot_url()
@@ -23,4 +28,4 @@ def test_delete_screenshot(self):
     def test_no_screenshot(self):
         feedback = FeedbackFactory(screenshot=None)
         feedback.delete()
-        self.assertFalse(feedback.screenshot)
+        self.assertFalse(feedback.screenshot)
\ No newline at end of file
diff --git a/tellme/tests/test_views.py b/tellme/tests/test_views.py
index cd29034..4288e57 100644
--- a/tellme/tests/test_views.py
+++ b/tellme/tests/test_views.py
@@ -102,10 +102,10 @@ def test_screenshot_view(self):
         feedback = Feedback.objects.create(
             url=fake.url(),
             browser=fake.user_agent(),
-            note=fake.sentence(),
-            img=make_base64_img(),
+            comment=fake.sentence(),
+            screenshot=make_base64_img(),
             email=fake.email(),
         )
         response = self.client.get(feedback.get_screenshot_url())
-        self.assertEqual(response.status_code, 301)
-        self.assertEqual(response['Location'], feedback.screenshot.url)
+        self.assertEqual(response.status_code, 302)
+        self.assertEqual(response['Location'], feedback.screenshot.url)
\ No newline at end of file