Skip to content

Commit 77d14a1

Browse files
authored
Version 2.1.0, repo migration with better VERSION. (#1)
* Version 0.1.0, repo migration with better VERSION. * Add more badges in README and change project url in setup.py. * Bump version to 2.1.0 * Add Chinese version README. * Minor typo.
1 parent 15c6b00 commit 77d14a1

19 files changed

+534
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# Custom
132+
config.py

.pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[SIMILARITIES]
2+
ignore-imports=yes

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include LICENSE
2+
include README.md
3+
include VERSION

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.PHONY: clean install dev lint pycodestyle pyflakes pylint test dist upload
2+
3+
clean:
4+
find . -name '*.pyc' -print0 | xargs -0 rm -f
5+
find . -name '*.swp' -print0 | xargs -0 rm -f
6+
find . -name '.DS_Store' -print0 | xargs -0 rm -rf
7+
find . -name '__pycache__' -print0 | xargs -0 rm -rf
8+
-rm -rf build dist *.egg-info
9+
-rm -rf .tox .coverage
10+
11+
install:
12+
pip install .
13+
14+
dev:
15+
pip install .[dev]
16+
17+
lint: pycodestyle pyflakes pylint
18+
19+
pycodestyle:
20+
-pycodestyle setup.py wxpusher
21+
22+
pyflakes:
23+
-pyflakes setup.py wxpusher
24+
25+
pylint:
26+
-pylint setup.py wxpusher
27+
28+
test:
29+
tox
30+
31+
dist: clean
32+
python setup.py sdist bdist_wheel
33+
34+
upload:
35+
twine upload dist/*

README-en.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# WxPusher
2+
3+
[![PyPI version](https://badge.fury.io/py/wxpusher.svg)](https://badge.fury.io/py/wxpusher)
4+
[![PyPI license](https://img.shields.io/pypi/l/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
5+
[![Python Versions](https://img.shields.io/pypi/pyversions/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
6+
[![Downloads](https://pepy.tech/badge/wxpusher)](https://pepy.tech/project/wxpusher)
7+
8+
WxPusher Python SDK.
9+
10+
*Read this in other languages: [English](README-en.md), [简体中文](README.md).*
11+
12+
## Getting Started
13+
14+
### Installation
15+
16+
```shell
17+
pip install -U wxpusher
18+
```
19+
20+
### Usage
21+
22+
```python
23+
from wxpusher import WxPusher
24+
WxPusher.send_message('<content>', '<uids>', '<appToken>')
25+
WxPusher.query_message('<messageId>')
26+
WxPusher.create_qrcode('<extra>', '<validTime>', '<appToken>')
27+
WxPusher.query_user('<page>', '<page_size>', '<appToken>')
28+
```
29+
30+
## Running the tests
31+
32+
### Setup configuration
33+
34+
Configuration is necessary since the tests depend on VALID `appToken` and `uids`.
35+
36+
Frist, copy the configuration sample `config.sample.py` under `python/wxpusher/tests/` to `config.py`
37+
38+
```shell
39+
cd python/wxpusher/tests
40+
cp config.sample.py config.py
41+
```
42+
43+
Then, fill in the corresponding information in `config.py`.
44+
45+
### Trigger the tests
46+
47+
With proper configuration, you can run the tests with tox
48+
49+
```shell
50+
tox
51+
```
52+
53+
or nose directly
54+
55+
```shell
56+
nosetests
57+
```
58+
59+
## TODO
60+
61+
- [x] Basic structure with PyPI uploaded.
62+
- [x] Send Message.
63+
- [x] Query Message.
64+
- [x] Create QRCode.
65+
- [x] Query User.
66+
- [ ] More client validators.
67+
- [ ] Command line scripts.
68+
- [ ] Better documentation.
69+
- [ ] More robust unittest.
70+
71+
## Contribution
72+
73+
- Comments or suggestions via github issues.
74+
- Pull requests are welcome absolutely.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# WxPusher
2+
3+
[![PyPI version](https://badge.fury.io/py/wxpusher.svg)](https://badge.fury.io/py/wxpusher)
4+
[![PyPI license](https://img.shields.io/pypi/l/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
5+
[![Python Versions](https://img.shields.io/pypi/pyversions/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
6+
[![Downloads](https://pepy.tech/badge/wxpusher)](https://pepy.tech/project/wxpusher)
7+
8+
WxPusher Python SDK.
9+
10+
*其他语言版本: [English](README-en.md), [简体中文](README.md).*
11+
12+
## 入门指南
13+
14+
### 安装
15+
16+
```shell
17+
pip install -U wxpusher
18+
```
19+
20+
### 使用
21+
22+
```python
23+
from wxpusher import WxPusher
24+
WxPusher.send_message('<content>', '<uids>', '<appToken>')
25+
WxPusher.query_message('<messageId>')
26+
WxPusher.create_qrcode('<extra>', '<validTime>', '<appToken>')
27+
WxPusher.query_user('<page>', '<page_size>', '<appToken>')
28+
```
29+
30+
## 运行测试
31+
32+
### 配置
33+
34+
运行测试需要配置好 `appToken``uids`
35+
36+
首先,将 `wxpusher/tests/` 文件夹下的配置样例 `config.sample.py` 复制并命名为 `config.py`
37+
38+
```shell
39+
cd python/wxpusher/tests
40+
cp config.sample.py config.py
41+
```
42+
43+
然后,填写 `config.py` 中的相应信息。
44+
45+
### 启动测试
46+
47+
配置好后就可以使用 `tox` 来运行测试了。
48+
49+
```shell
50+
tox
51+
```
52+
53+
或者直接使用 `nose` 也可以
54+
55+
```shell
56+
nosetests
57+
```
58+
59+
## TODO
60+
61+
- [x] 基本架构并上传到 PyPI
62+
- [x] 发送消息.
63+
- [x] 查询消息.
64+
- [x] 创建二维码.
65+
- [x] 查询用户.
66+
- [ ] 更完备的客户端验证.
67+
- [ ] 命令行脚本.
68+
- [ ] 更完善的文档.
69+
- [ ] 更完备的单元测试.
70+
71+
## 贡献
72+
73+
- 通过 Github Issues 提交评论或建议。
74+
- 直接提交 Pull Requests 必须没问题。

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.1.0

setup.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: setup.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: Python packaging for wxpusher.
8+
"""
9+
from setuptools import setup
10+
11+
CLASSIFIERS = [
12+
'Development Status :: 4 - Beta',
13+
'Intended Audience :: Developers',
14+
'License :: OSI Approved :: Apache Software License',
15+
'Programming Language :: Python :: 3',
16+
'Programming Language :: Python :: 3 :: Only',
17+
'Topic :: Utilities'
18+
]
19+
20+
INSTALL_REQUIRES = [
21+
'requests'
22+
]
23+
24+
DEV_REQUIRES = [
25+
'pycodestyle',
26+
'pyflakes',
27+
'pylint'
28+
]
29+
30+
TEST_REQUIRES = [
31+
'coverage',
32+
'nose'
33+
]
34+
35+
EXTRAS_REQUIRE = {
36+
'dev': DEV_REQUIRES,
37+
'test': TEST_REQUIRES
38+
}
39+
40+
DESCRIPTION = (
41+
'WxPusher Python SDK.'
42+
)
43+
44+
45+
def readme():
46+
"""Parse README for long_description."""
47+
with open('README.md') as fin:
48+
return fin.read()
49+
50+
51+
setup(name='wxpusher',
52+
version=open('VERSION').read().strip(),
53+
description=DESCRIPTION,
54+
long_description=readme(),
55+
long_description_content_type='text/markdown',
56+
classifiers=CLASSIFIERS,
57+
keywords='wxpusher wechat push-notification',
58+
url='https://github.com/wxpusher/wxpusher-sdk-python',
59+
author='Xuan (Sean) Hu',
60+
author_email='[email protected]',
61+
license='Apache License 2.0',
62+
packages=['wxpusher'],
63+
install_requires=INSTALL_REQUIRES,
64+
extras_require=EXTRAS_REQUIRE,
65+
python_requires='>=3',
66+
include_package_data=True)

tox.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# tox (https://tox.readthedocs.io/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
envlist = py3
8+
9+
[testenv]
10+
deps =
11+
.[test]
12+
commands =
13+
nosetests --with-coverage --cover-erase --cover-package=wxpusher

wxpusher/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: __init__.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: init for WxPusher.
8+
"""
9+
from .wxpusher import WxPusher
10+
from .exceptions import WxPusherException
11+
from .exceptions import WxPusherNoneTokenException
12+
13+
__all__ = [
14+
'WxPusher',
15+
'WxPusherException',
16+
'WxPusherNoneTokenException'
17+
]
18+
19+
__version__ = open('VERSION').read().strip()

wxpusher/exceptions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: exceptions.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: WxPusher Exceptions.
8+
"""
9+
10+
11+
class WxPusherException(Exception):
12+
"""WxPusher specific base exception."""
13+
14+
15+
class WxPusherNoneTokenException(WxPusherException):
16+
"""Raised when both token and default token are None."""

wxpusher/tests/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: __init__.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: Init for unittest.
8+
"""
9+
from . import exceptions
10+
11+
try:
12+
from . import config
13+
except ImportError:
14+
raise exceptions.WxPusherTestNoConfigException
15+
16+
__all__ = ['config']

wxpusher/tests/config.sample.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: config.sample.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: Unittest configuration sample.
8+
"""
9+
# the `appToken` for test.
10+
TOKEN = ''
11+
12+
# the `uids` for test, note that it should be a list.
13+
UIDS = [
14+
''
15+
]

wxpusher/tests/exceptions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: exceptions.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: Custom exceptions for unittest.
8+
"""
9+
from wxpusher import WxPusherException
10+
11+
12+
class WxPusherTestNoConfigException(WxPusherException):
13+
"""Raised when no unittest configuration exists."""

wxpusher/tests/test_create_qrcode.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: test_create_qrcode.py
5+
Author: huxuan
6+
Email: i(at)huxuan.org
7+
Description: Unittest for creating qrcode.
8+
"""
9+
import unittest
10+
11+
from wxpusher import WxPusher
12+
13+
from . import config
14+
15+
16+
class TestCreateQRCode(unittest.TestCase):
17+
"""Unittest for creating qrcode."""
18+
19+
@classmethod
20+
def setUpClass(cls):
21+
WxPusher.default_token = config.TOKEN
22+
23+
def test_create_qrcode(self):
24+
"""Positive case for creating qrcode."""
25+
res = WxPusher.create_qrcode(
26+
self.test_create_qrcode.__doc__
27+
)
28+
self.assertIsInstance(res, dict)
29+
self.assertIn('code', res)
30+
self.assertEqual(1000, res['code'])

0 commit comments

Comments
 (0)