-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13f9dfe
commit 8645f64
Showing
8 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | ||
try: | ||
__import__('pkg_resources').declare_namespace(__name__) | ||
except ImportError: | ||
from pkgutil import extend_path | ||
__path__ = locals()['__path__'] # make PyFlakes happy | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | ||
try: | ||
__import__('pkg_resources').declare_namespace(__name__) | ||
except ImportError: | ||
from pkgutil import extend_path | ||
__path__ = locals()['__path__'] # make PyFlakes happy | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
#:coding=utf-8: | ||
|
||
import os | ||
from setuptools import setup, find_packages | ||
|
||
def read_file(filename): | ||
basepath = os.path.dirname(__file__) | ||
filepath = os.path.join(basepath, filename) | ||
with open(filepath) as f: | ||
read_text = f.read() | ||
return read_text | ||
|
||
|
||
setup( | ||
name='bpnotify', | ||
version='0.48', | ||
description='Notification routing for Django', | ||
author='BeProud', | ||
author_email='[email protected]', | ||
long_description=read_file('README.rst'), | ||
long_description_content_type="text/x-rst", | ||
url='https://github.com/beproud/bpnotify/', | ||
python_requires='>=3.6', | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', | ||
'Environment :: Plugins', | ||
'Framework :: Django', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: BSD License', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.9', | ||
'Framework :: Django', | ||
'Framework :: Django :: 2.2', | ||
'Framework :: Django :: 3.2', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
], | ||
include_package_data=True, | ||
packages=find_packages(), | ||
namespace_packages=['beproud', 'beproud.django'], | ||
test_suite='tests.main', | ||
install_requires=[ | ||
'Django>=2.2', | ||
'django-jsonfield>=1.0.1', | ||
'Celery>=4.2', | ||
'six', | ||
], | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Django3では、標準のdjango.conf.global_settingsの定数をオーバーライドすると例外が発生する場合がある。 | ||
# https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188 | ||
# そのため、testではdjango.conf.global_settingsを直接利用せず、このtest用settings定数を使用する。 | ||
|
||
import os | ||
|
||
SECRET_KEY = "SECRET" | ||
INSTALLED_APPS = ( | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'beproud.django.notify', | ||
) | ||
|
||
# kombu.exceptions.EncodeError: Object of type User is not JSON serializable エラーを抑止する | ||
# (参考) | ||
# https://github.com/celery/celery/issues/5922 | ||
# https://stackoverflow.com/questions/49373825/kombu-exceptions-encodeerror-user-is-not-json-serializable | ||
CELERY_TASK_SERIALIZER = "pickle" | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': ':memory:', | ||
} | ||
} | ||
|
||
BASE_PATH = os.path.dirname(__file__) | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [ | ||
os.path.join(BASE_PATH, 'beproud', 'django', 'notify', 'tests', 'templates') | ||
], | ||
}, | ||
] | ||
|
||
CELERY_TASK_ALWAYS_EAGER = True | ||
|
||
BPNOTIFY_MEDIA = { | ||
"news": { | ||
"verbose_name": "News", | ||
"default_types": ("new_user", "follow", "private_msg"), | ||
"backends": ( | ||
"beproud.django.notify.backends.model.ModelBackend", | ||
), | ||
}, | ||
"private_messages": { | ||
"verbose_name": "Private Message", | ||
"default_types": ("private_msg", "notify_type_with_length_over_thirty"), | ||
"backends": ( | ||
"beproud.django.notify.backends.model.ModelBackend", | ||
"beproud.django.notify.backends.mail.EmailBackend", | ||
), | ||
}, | ||
} | ||
BPNOTIFY_SETTINGS_STORAGE = 'beproud.django.notify.storage.db.DBStorage' | ||
|
||
# The name of the class to use to run the test suite | ||
TEST_RUNNER = 'django.test.runner.DiscoverRunner' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import sys | ||
import django | ||
import celery | ||
|
||
import test_settings | ||
|
||
BASE_PATH = os.path.dirname(__file__) | ||
|
||
|
||
def main(): | ||
""" | ||
Standalone django model test with a 'memory-only-django-installation'. | ||
You can play with a django model without a complete django app installation. | ||
http://www.djangosnippets.org/snippets/1044/ | ||
""" | ||
|
||
# Django標準のdjango.conf.global_settingsを設定してしまうと、 | ||
# Django3では、global_settingsの全ての定数を上書きする挙動になってしまい、 | ||
# Django3の仕様で、多重上書き禁止エラーが検知され、例外が発生する。 | ||
# (例) https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188 | ||
# そのため、自前のテスト用settingsモジュール(test_settings.py)を設定する。 | ||
os.environ["DJANGO_SETTINGS_MODULE"] = "test_settings" | ||
|
||
app = celery.Celery() | ||
app.config_from_object('django.conf:settings', namespace='CELERY') | ||
app.autodiscover_tasks(lambda: test_settings.INSTALLED_APPS) | ||
|
||
django.setup() | ||
|
||
from django.test.utils import get_runner | ||
|
||
# test用のsettings情報を用いて、Djangoのtest runnerクラスを取得 | ||
TestRunner = get_runner(test_settings) | ||
|
||
# test runnerオブジェクトを生成 | ||
test_runner = TestRunner() | ||
|
||
# test runnerにbpnotifyの単体テストのPathを渡して、bpnotifyの単体テストを実行する | ||
failures = test_runner.run_tests(['beproud.django.notify.tests']) | ||
|
||
sys.exit(failures) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters