Skip to content

Commit

Permalink
feat: support django 3.2 to gitlab-ci, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Agus Makmun committed Nov 18, 2021
1 parent ae80bfd commit 7e8c732
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 24 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ matrix:
env: DJANGO="==3.0.*"
- python: 3.6
env: DJANGO="==3.1.*"
- python: 3.6
env: DJANGO="==3.2.*"

- python: 3.7
env: DJANGO="==2.0.*"
Expand All @@ -32,6 +34,8 @@ matrix:
env: DJANGO="==3.0.*"
- python: 3.7
env: DJANGO="==3.1.*"
- python: 3.7
env: DJANGO="==3.2.*"

- python: 3.8
env: DJANGO="==2.0.*"
Expand All @@ -43,6 +47,8 @@ matrix:
env: DJANGO="==3.0.*"
- python: 3.8
env: DJANGO="==3.1.*"
- python: 3.8
env: DJANGO="==3.2.*"

- python: 3.9
env: DJANGO="==2.0.*"
Expand All @@ -54,10 +60,12 @@ matrix:
env: DJANGO="==3.0.*"
- python: 3.9
env: DJANGO="==3.1.*"
- python: 3.9
env: DJANGO="==3.2.*"

- os: osx
language: generic
env: DJANGO="==3.1.*"
env: DJANGO="==3.2.*"

# Perform the manual steps on OSX to install Python3 and activate venv:
# Since Python versions have been tested on Linux and it is only a matter of
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Checkout at http://127.0.0.1:8000/simple-form/ on your browser.
[7]: https://img.shields.io/pypi/pyversions/martor.svg
[8]: https://pypi.python.org/pypi/martor

[9]: https://img.shields.io/badge/Django-1.8%20%3E=%203.1-green.svg
[9]: https://img.shields.io/badge/Django-1.8%20%3E=%203.2-green.svg
[10]: https://www.djangoproject.com

[11]: https://travis-ci.org/agusmakmun/django-markdown-editor.svg?branch=master
Expand Down
2 changes: 1 addition & 1 deletion martor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

__VERSION__ = '1.6.4'
__VERSION__ = '1.6.5'
__AUTHOR__ = 'Agus Makmun (Summon Agus)'
__AUTHOR_EMAIL__ = 'summon.agus@gmail.com'
4 changes: 2 additions & 2 deletions martor/static/martor/css/martor-admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions martor/static/martor/css/martor.bootstrap.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions martor/static/martor/css/martor.semantic.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.4
* Name : Martor v1.6.5
* Created by : Agus Makmun (Summon Agus)
* Release date : 15-Jul-2021
* Release date : 18-Nov-2021
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.bootstrap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.semantic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.4
* Name : Martor v1.6.5
* Created by : Agus Makmun (Summon Agus)
* Release date : 15-Jul-2021
* Release date : 18-Nov-2021
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.semantic.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 70 additions & 3 deletions martor/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,79 @@
from django.test import TestCase
from django.test import TestCase, override_settings
from django.contrib.auth.models import User
from martor.utils import markdownify, VersionNotCompatible


class SimpleTest(TestCase):

def test_me(self):
def setUp(self):
self.user = User.objects.create_user(
username='user1',
email='user1@mail.com',
password='TestEgg@1234',
is_active=True
)
self.client.force_login(self.user)

def test_form(self):
response = self.client.get('/test-form-view/')
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed('test_form_view.html')
self.assertContains(response, 'main-martor-description')
self.assertContains(response, 'main-martor-wiki')

@override_settings(MARTOR_ENABLE_CONFIGS={
'emoji': 'true', # enable/disable emoji icons.
'imgur': 'true', # enable/disable imgur/custom uploader.
'mention': 'true', # enable/disable mention
'jquery': 'true', # include/revoke jquery (require for admin django)
'living': 'false', # enable/disable live updates in preview
'spellcheck': 'false', # enable/disable spellcheck in form textareas
'hljs': 'true', # enable/disable hljs highlighting in preview
})
def test_markdownify(self):
# Heading
response = self.client.post(
'/martor/markdownify/',
{'content': '# Hello world!'}
)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.content.decode('utf-8'),
'<h1>Hello world!</h1>'
)

# Link
response = self.client.post(
'/martor/markdownify/',
{'content': '[python](https://python.web.id)'}
)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.content.decode('utf-8'),
'<p><a href="https://python.web.id">python</a></p>'
)

# Image
response = self.client.post(
'/martor/markdownify/',
{'content': '![image](https://imgur.com/test.png)'}
)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.content.decode('utf-8'),
'<p><img alt="image" src="https://imgur.com/test.png" /></p>'
)

# # Mention
# response = self.client.post(
# '/martor/markdownify/',
# {'content': f'@[{self.user.username}]'}
# )
# self.assertEqual(response.status_code, 200)
# self.assertEqual(
# response.content.decode('utf-8'),
# '...fixme'
# )

def test_markdownify_error(self,):
# This tests that real errors don't raise VersionNotCompatible
Expand All @@ -16,4 +83,4 @@ def test_markdownify_error(self,):
except Exception as e:
self.assertNotIsInstance(e, VersionNotCompatible)
else:
self.fail("no assertion raised")
self.fail('no assertion raised')
9 changes: 5 additions & 4 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

settings.configure(
SECRET_KEY='xxxxx',
DEBUG=True,
DATABASES={
'default': {
Expand Down Expand Up @@ -51,14 +52,14 @@
)

try:
# Django <= 1.8
from django.test.simple import DjangoTestSuiteRunner
test_runner = DjangoTestSuiteRunner(verbosity=1)
except ImportError:
# Django >= 1.8
django.setup()
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=1)
except (ImportError, ModuleNotFoundError):
# Django <= 1.8
from django.test.simple import DjangoTestSuiteRunner
test_runner = DjangoTestSuiteRunner(verbosity=1)

failures = test_runner.run_tests(['martor'])
if failures:
Expand Down

0 comments on commit 7e8c732

Please sign in to comment.