Skip to content

Commit be1bfa8

Browse files
committed
Create pipeline
1 parent e7c4124 commit be1bfa8

16 files changed

Lines changed: 226 additions & 144 deletions
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
lint:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- uses: actions/checkout@v2
15-
- name: Set up Python 2
16-
uses: actions/setup-python@v2
17-
with:
18-
python-version: 2.7
19-
- name: lint
20-
run: make lint
2110

2211
fmt:
2312
runs-on: ubuntu-latest
@@ -34,7 +23,7 @@ jobs:
3423
runs-on: ubuntu-latest
3524
strategy:
3625
matrix:
37-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy-2.7, pypy-3.7]
26+
python-version: [3.6, 3.7, 3.8, 3.9, pypy-3.7]
3827

3928
steps:
4029
- uses: actions/checkout@v2
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [create]
14+
15+
jobs:
16+
17+
fmt:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python 3
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: 3.9
25+
- name: fmtcheck
26+
run: make fmtcheck
27+
28+
build:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: [3.6, 3.7, 3.8, 3.9, pypy-3.7]
33+
34+
steps:
35+
- uses: actions/checkout@v2
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Upgrade pip and virtualenv to latest
42+
run: pip install --upgrade pip virtualenv
43+
- name: Get pip cache dir
44+
id: pip-cache
45+
run: |
46+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
47+
- name: pip cache
48+
uses: actions/cache@v2
49+
with:
50+
path: ${{ steps.pip-cache.outputs.dir }}
51+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
52+
restore-keys: |
53+
${{ runner.os }}-pip-
54+
55+
- name: Test with pytest
56+
run: make test
57+
58+
deploy:
59+
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- uses: actions/checkout@v2
64+
- name: Set up Python
65+
uses: actions/setup-python@v2
66+
with:
67+
python-version: '3.x'
68+
- name: Install dependencies
69+
run: |
70+
python -m pip install --upgrade pip
71+
pip install build
72+
- name: Build package
73+
run: python -m build
74+
- name: Publish package
75+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
76+
with:
77+
user: __token__
78+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ venv
44
.vscode
55
build
66
dist
7+
pyvenv.cfg
8+
.tox
9+
bin

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
55

6+
67
def get_long_description():
78
return open(os.path.join(ROOT_DIR, "README.md")).read()
89

10+
911
setup(
1012
name="twikey-api-python",
1113
version="v0.1.0",
@@ -23,7 +25,7 @@ def get_long_description():
2325
'requests >= 2.20; python_version >= "3.0"',
2426
'requests[security] >= 2.20; python_version < "3.0"',
2527
],
26-
python_requires=">=3.0",
28+
python_requires=">=3.6",
2729
project_urls={
2830
"Bug Tracker": "https://github.com/twikey/twikey-api-python/issues",
2931
"Source Code": "https://github.com/twikey/twikey-api-python",
@@ -35,11 +37,7 @@ def get_long_description():
3537
"License :: OSI Approved :: MIT License",
3638
"Operating System :: OS Independent",
3739
"Programming Language :: Python",
38-
"Programming Language :: Python :: 2",
39-
"Programming Language :: Python :: 2.7",
4040
"Programming Language :: Python :: 3",
41-
"Programming Language :: Python :: 3.4",
42-
"Programming Language :: Python :: 3.5",
4341
"Programming Language :: Python :: 3.6",
4442
"Programming Language :: Python :: 3.7",
4543
"Programming Language :: Python :: 3.8",

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Set to either 'debug' or 'info', controls console logging
44
log = None
55

6-
# Webhooks
6+
# Webhooks

tests/test_document.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,31 @@ def test_new_invite(self):
1818
ct = 1
1919
if "CT" in os.environ:
2020
ct = os.environ["CT"]
21-
invite = self._twikey.document.create({
22-
"ct": ct,
23-
"email": "info@twikey.com",
24-
"firstname": "Info",
25-
"lastname": "Twikey",
26-
"l": "en",
27-
"address": "Abby road",
28-
"city": "Liverpool",
29-
"zip": "1526",
30-
"country": "BE",
31-
"mobile": "",
32-
"iban": "",
33-
"bic": "",
34-
"mandateNumber": "",
35-
"contractNumber": ""
36-
})
21+
invite = self._twikey.document.create(
22+
{
23+
"ct": ct,
24+
"email": "info@twikey.com",
25+
"firstname": "Info",
26+
"lastname": "Twikey",
27+
"l": "en",
28+
"address": "Abby road",
29+
"city": "Liverpool",
30+
"zip": "1526",
31+
"country": "BE",
32+
"mobile": "",
33+
"iban": "",
34+
"bic": "",
35+
"mandateNumber": "",
36+
"contractNumber": "",
37+
}
38+
)
3739
self.assertIsNotNone(invite)
3840

3941
def test_feed(self):
4042
self._twikey.document.feed(MyDocumentFeed())
4143

4244

4345
class MyDocumentFeed(twikey.DocumentFeed):
44-
4546
def newDocument(self, doc):
4647
print("new ", doc["MndtId"])
4748

@@ -52,5 +53,5 @@ def cancelDocument(self, docNumber, reason):
5253
print("cancelled ", docNumber, "b/c", reason["Rsn"])
5354

5455

55-
if __name__ == '__main__':
56+
if __name__ == "__main__":
5657
unittest.main()

tests/test_invoices.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import twikey
33
import unittest
44

5+
56
class TestInvoices(unittest.TestCase):
67
_twikey = None
78

@@ -18,39 +19,40 @@ def setUp(self):
1819
self._twikey = twikey.TwikeyClient(key, baseUrl)
1920

2021
def test_new_invite(self):
21-
invoice = self._twikey.invoice.create({
22-
"number": "Inv20200001",
23-
"title": "Invoice July",
24-
"remittance": "596843697521",
25-
"ct": 1988,
26-
"amount": 100,
27-
"date": "2020-01-31",
28-
"duedate": "2020-02-28",
29-
"customer": {
30-
"customerNumber": "customer123",
31-
"email": "no-reply@twikey.com",
32-
"firstname": "Twikey",
33-
"lastname": "Support",
34-
"address": "Derbystraat 43",
35-
"city": "Gent",
36-
"zip": "9000",
37-
"country": "BE",
38-
"l": "nl",
39-
"mobile": "32498665995"
40-
},
41-
# "pdf": "JVBERi0xLj....RU9GCg=="
42-
})
22+
invoice = self._twikey.invoice.create(
23+
{
24+
"number": "Inv20200001",
25+
"title": "Invoice July",
26+
"remittance": "596843697521",
27+
"ct": 1988,
28+
"amount": 100,
29+
"date": "2020-01-31",
30+
"duedate": "2020-02-28",
31+
"customer": {
32+
"customerNumber": "customer123",
33+
"email": "no-reply@twikey.com",
34+
"firstname": "Twikey",
35+
"lastname": "Support",
36+
"address": "Derbystraat 43",
37+
"city": "Gent",
38+
"zip": "9000",
39+
"country": "BE",
40+
"l": "nl",
41+
"mobile": "32498665995",
42+
},
43+
# "pdf": "JVBERi0xLj....RU9GCg=="
44+
}
45+
)
4346
self.assertIsNotNone(invoice)
4447

4548
def test_feed(self):
4649
self._twikey.document.feed(MyFeed())
4750

4851

4952
class MyFeed(twikey.TransactionFeed):
50-
5153
def transaction(self, transaction):
5254
print("new ", transaction.ref, transaction.state)
5355

5456

55-
if __name__ == '__main__':
57+
if __name__ == "__main__":
5658
unittest.main()

tests/test_paylinks.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import twikey
33
import unittest
44

5+
56
class TestPaylinks(unittest.TestCase):
67
_twikey = None
78

@@ -18,23 +19,24 @@ def setUp(self):
1819
self._twikey = twikey.TwikeyClient(key, baseUrl)
1920

2021
def test_new_invite(self):
21-
tx = self._twikey.paylink.create({
22-
"email": "no-repy@twikey.com",
23-
"message": "Test Message",
24-
"ref": "Merchant Reference",
25-
"amount": 10.00
26-
})
22+
tx = self._twikey.paylink.create(
23+
{
24+
"email": "no-repy@twikey.com",
25+
"message": "Test Message",
26+
"ref": "Merchant Reference",
27+
"amount": 10.00,
28+
}
29+
)
2730
self.assertIsNotNone(tx)
2831

2932
def test_feed(self):
3033
self._twikey.paylink.feed(MyFeed())
3134

3235

3336
class MyFeed(twikey.PaylinkFeed):
34-
3537
def paylink(self, paylink):
3638
print("new ", paylink)
3739

3840

39-
if __name__ == '__main__':
41+
if __name__ == "__main__":
4042
unittest.main()

tests/test_transaction.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import twikey
33
import unittest
44

5+
56
class TestTransaction(unittest.TestCase):
67
_twikey = None
78

@@ -18,24 +19,25 @@ def setUp(self):
1819
self._twikey = twikey.TwikeyClient(key, baseUrl)
1920

2021
def test_new_invite(self):
21-
tx = self._twikey.transaction.create({
22-
"mndtId": "CORERECURRENTNL16318",
23-
"message": "Test Message",
24-
"ref": "Merchant Reference",
25-
"amount": 10.00,
26-
"place": "Here"
27-
})
22+
tx = self._twikey.transaction.create(
23+
{
24+
"mndtId": "CORERECURRENTNL16318",
25+
"message": "Test Message",
26+
"ref": "Merchant Reference",
27+
"amount": 10.00,
28+
"place": "Here",
29+
}
30+
)
2831
self.assertIsNotNone(tx)
2932

3033
def test_feed(self):
3134
self._twikey.document.feed(MyFeed())
3235

3336

3437
class MyFeed(twikey.TransactionFeed):
35-
3638
def transaction(self, transaction):
3739
print("new ", transaction.ref, transaction.state)
3840

3941

40-
if __name__ == '__main__':
42+
if __name__ == "__main__":
4143
unittest.main()

0 commit comments

Comments
 (0)