Skip to content

Commit

Permalink
Version 2.1.0, repo migration with better VERSION. (#1)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
huxuan authored Jan 17, 2020
1 parent 15c6b00 commit 77d14a1
Show file tree
Hide file tree
Showing 19 changed files with 534 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Custom
config.py
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[SIMILARITIES]
ignore-imports=yes
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE
include README.md
include VERSION
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.PHONY: clean install dev lint pycodestyle pyflakes pylint test dist upload

clean:
find . -name '*.pyc' -print0 | xargs -0 rm -f
find . -name '*.swp' -print0 | xargs -0 rm -f
find . -name '.DS_Store' -print0 | xargs -0 rm -rf
find . -name '__pycache__' -print0 | xargs -0 rm -rf
-rm -rf build dist *.egg-info
-rm -rf .tox .coverage

install:
pip install .

dev:
pip install .[dev]

lint: pycodestyle pyflakes pylint

pycodestyle:
-pycodestyle setup.py wxpusher

pyflakes:
-pyflakes setup.py wxpusher

pylint:
-pylint setup.py wxpusher

test:
tox

dist: clean
python setup.py sdist bdist_wheel

upload:
twine upload dist/*
74 changes: 74 additions & 0 deletions README-en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# WxPusher

[![PyPI version](https://badge.fury.io/py/wxpusher.svg)](https://badge.fury.io/py/wxpusher)
[![PyPI license](https://img.shields.io/pypi/l/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
[![Python Versions](https://img.shields.io/pypi/pyversions/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
[![Downloads](https://pepy.tech/badge/wxpusher)](https://pepy.tech/project/wxpusher)

WxPusher Python SDK.

*Read this in other languages: [English](README-en.md), [简体中文](README.md).*

## Getting Started

### Installation

```shell
pip install -U wxpusher
```

### Usage

```python
from wxpusher import WxPusher
WxPusher.send_message('<content>', '<uids>', '<appToken>')
WxPusher.query_message('<messageId>')
WxPusher.create_qrcode('<extra>', '<validTime>', '<appToken>')
WxPusher.query_user('<page>', '<page_size>', '<appToken>')
```

## Running the tests

### Setup configuration

Configuration is necessary since the tests depend on VALID `appToken` and `uids`.

Frist, copy the configuration sample `config.sample.py` under `python/wxpusher/tests/` to `config.py`

```shell
cd python/wxpusher/tests
cp config.sample.py config.py
```

Then, fill in the corresponding information in `config.py`.

### Trigger the tests

With proper configuration, you can run the tests with tox

```shell
tox
```

or nose directly

```shell
nosetests
```

## TODO

- [x] Basic structure with PyPI uploaded.
- [x] Send Message.
- [x] Query Message.
- [x] Create QRCode.
- [x] Query User.
- [ ] More client validators.
- [ ] Command line scripts.
- [ ] Better documentation.
- [ ] More robust unittest.

## Contribution

- Comments or suggestions via github issues.
- Pull requests are welcome absolutely.
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# WxPusher

[![PyPI version](https://badge.fury.io/py/wxpusher.svg)](https://badge.fury.io/py/wxpusher)
[![PyPI license](https://img.shields.io/pypi/l/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
[![Python Versions](https://img.shields.io/pypi/pyversions/wxpusher.svg)](https://pypi.python.org/pypi/wxpusher/)
[![Downloads](https://pepy.tech/badge/wxpusher)](https://pepy.tech/project/wxpusher)

WxPusher Python SDK.

*其他语言版本: [English](README-en.md), [简体中文](README.md).*

## 入门指南

### 安装

```shell
pip install -U wxpusher
```

### 使用

```python
from wxpusher import WxPusher
WxPusher.send_message('<content>', '<uids>', '<appToken>')
WxPusher.query_message('<messageId>')
WxPusher.create_qrcode('<extra>', '<validTime>', '<appToken>')
WxPusher.query_user('<page>', '<page_size>', '<appToken>')
```

## 运行测试

### 配置

运行测试需要配置好 `appToken``uids`

首先,将 `wxpusher/tests/` 文件夹下的配置样例 `config.sample.py` 复制并命名为 `config.py`

```shell
cd python/wxpusher/tests
cp config.sample.py config.py
```

然后,填写 `config.py` 中的相应信息。

### 启动测试

配置好后就可以使用 `tox` 来运行测试了。

```shell
tox
```

或者直接使用 `nose` 也可以

```shell
nosetests
```

## TODO

- [x] 基本架构并上传到 PyPI
- [x] 发送消息.
- [x] 查询消息.
- [x] 创建二维码.
- [x] 查询用户.
- [ ] 更完备的客户端验证.
- [ ] 命令行脚本.
- [ ] 更完善的文档.
- [ ] 更完备的单元测试.

## 贡献

- 通过 Github Issues 提交评论或建议。
- 直接提交 Pull Requests 必须没问题。
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.0
66 changes: 66 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: setup.py
Author: huxuan
Email: i(at)huxuan.org
Description: Python packaging for wxpusher.
"""
from setuptools import setup

CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Utilities'
]

INSTALL_REQUIRES = [
'requests'
]

DEV_REQUIRES = [
'pycodestyle',
'pyflakes',
'pylint'
]

TEST_REQUIRES = [
'coverage',
'nose'
]

EXTRAS_REQUIRE = {
'dev': DEV_REQUIRES,
'test': TEST_REQUIRES
}

DESCRIPTION = (
'WxPusher Python SDK.'
)


def readme():
"""Parse README for long_description."""
with open('README.md') as fin:
return fin.read()


setup(name='wxpusher',
version=open('VERSION').read().strip(),
description=DESCRIPTION,
long_description=readme(),
long_description_content_type='text/markdown',
classifiers=CLASSIFIERS,
keywords='wxpusher wechat push-notification',
url='https://github.com/wxpusher/wxpusher-sdk-python',
author='Xuan (Sean) Hu',
author_email='[email protected]',
license='Apache License 2.0',
packages=['wxpusher'],
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
python_requires='>=3',
include_package_data=True)
13 changes: 13 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# tox (https://tox.readthedocs.io/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py3

[testenv]
deps =
.[test]
commands =
nosetests --with-coverage --cover-erase --cover-package=wxpusher
19 changes: 19 additions & 0 deletions wxpusher/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: __init__.py
Author: huxuan
Email: i(at)huxuan.org
Description: init for WxPusher.
"""
from .wxpusher import WxPusher
from .exceptions import WxPusherException
from .exceptions import WxPusherNoneTokenException

__all__ = [
'WxPusher',
'WxPusherException',
'WxPusherNoneTokenException'
]

__version__ = open('VERSION').read().strip()
16 changes: 16 additions & 0 deletions wxpusher/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: exceptions.py
Author: huxuan
Email: i(at)huxuan.org
Description: WxPusher Exceptions.
"""


class WxPusherException(Exception):
"""WxPusher specific base exception."""


class WxPusherNoneTokenException(WxPusherException):
"""Raised when both token and default token are None."""
16 changes: 16 additions & 0 deletions wxpusher/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: __init__.py
Author: huxuan
Email: i(at)huxuan.org
Description: Init for unittest.
"""
from . import exceptions

try:
from . import config
except ImportError:
raise exceptions.WxPusherTestNoConfigException

__all__ = ['config']
15 changes: 15 additions & 0 deletions wxpusher/tests/config.sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: config.sample.py
Author: huxuan
Email: i(at)huxuan.org
Description: Unittest configuration sample.
"""
# the `appToken` for test.
TOKEN = ''

# the `uids` for test, note that it should be a list.
UIDS = [
''
]
13 changes: 13 additions & 0 deletions wxpusher/tests/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: exceptions.py
Author: huxuan
Email: i(at)huxuan.org
Description: Custom exceptions for unittest.
"""
from wxpusher import WxPusherException


class WxPusherTestNoConfigException(WxPusherException):
"""Raised when no unittest configuration exists."""
30 changes: 30 additions & 0 deletions wxpusher/tests/test_create_qrcode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: test_create_qrcode.py
Author: huxuan
Email: i(at)huxuan.org
Description: Unittest for creating qrcode.
"""
import unittest

from wxpusher import WxPusher

from . import config


class TestCreateQRCode(unittest.TestCase):
"""Unittest for creating qrcode."""

@classmethod
def setUpClass(cls):
WxPusher.default_token = config.TOKEN

def test_create_qrcode(self):
"""Positive case for creating qrcode."""
res = WxPusher.create_qrcode(
self.test_create_qrcode.__doc__
)
self.assertIsInstance(res, dict)
self.assertIn('code', res)
self.assertEqual(1000, res['code'])
Loading

0 comments on commit 77d14a1

Please sign in to comment.