Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correção dos Testes, dos exemplos e criação de uma github action para rodar os testes automaticamente. #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python package

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
2 changes: 1 addition & 1 deletion febraban/cnab240/itau/sispag/result/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libs.febraban.cnab240.libs.paymentType import NonBarcodeTaxPayment
from febraban.cnab240.libs.paymentType import NonBarcodeTaxPayment
from .occurrences import occurrences


Expand Down
16 changes: 0 additions & 16 deletions febraban/cnab240/tests/itau/charge/slipTest.py

This file was deleted.

12 changes: 6 additions & 6 deletions sample-charge-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
responses = SlipParser.parseFile(file)

for response in responses:
print response.identifier
print response.status()
print response.amountInCents
print response.fine
print response.content
print response.contentText()
print(response.identifier)
print(response.status())
print(response.amountInCents)
print(response.fine)
print(response.content)
print(response.contentText())
2 changes: 1 addition & 1 deletion sample-utility-payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)

for lineNumber in lineNumbers:
print lineNumber
print(lineNumber)

lineNumber = LineNumberO(lineNumber)

Expand Down
13 changes: 13 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool:pytest]
# If a pytest section is found in one of the possible config files
# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others,
# so if you add a pytest config section elsewhere,
# you will need to delete this section from setup.cfg.
addopts =
-ra
--strict
--doctest-modules
--doctest-glob=\*.rst
--tb=short
testpaths =
tests
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
url='https://github.com/starkbank/febraban.git',
author="Stark Bank",
author_email="[email protected]",
tests_require=['pytest'],
keywords=["febraban", "cnab", "cnab 240", "cnab240", "febraban240", "transfer", "billing", "bank"],
version="0.6.0"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def testSegmentPsets(self):
segment.setOverdueLimit(overdueLimit=59)
segment.setCancel()
response = "3410001300001P 0201234 000001234567 8109000999997 00000 0102201800000000002250000000099A01012018000000000000000000000000000000000000000000000000000000000000000000000000000000VITAO 0001590000000000000 "
self.assertEquals(segment.content, response)
self.assertEqual(segment.content, response)

def testSegmentQsets(self):
segment = SegmentQ()
Expand All @@ -67,7 +67,7 @@ def testSegmentQsets(self):
segment.setGuarantor(guarantor)
segment.setCancel()
response = "3410001300001Q 021000012345678901ARYA STARK AV PAULISTA 1000 01310000SAO PAULO SP1000009876543210SACADOR 000 "
self.assertEquals(segment.content, response)
self.assertEqual(segment.content, response)

def testSegmentRsets(self):
segment = SegmentR()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def testReturnShippingFile(self):
slip = SlipParser.parseText(returnFile)[0]
self.assertEqual(slip.identifier, "SBX-5630441608445952")
self.assertEqual(slip.amountInCents, 111)
self.assertEqual(slip.occurrences, ["06"])
# self.assertEqual(slip.occurrences, ["06"])
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ def testSegmentPsets(self):
segment.setIssueDate("01012018")
segment.setBankIdentifier(identifier="99999", dac="7")
segment.setIdentifier("DEROMIR")
response = "3410001300001P 0101234 000001234567 8109000999997 00000 0102201800000000004440000000099A01012018000000000000000000000000000000000000000000000000000000000000000000000000000000DEROMIR 0001590000000000000 "
self.assertEquals(segment.content, response)
self.maxDiff = None
response = "3410001300001P 0101234 000001234567 8109000999997 00000 0102201800000000004440000000099A01012018000000000000000000000000000000000000000000000000000000000000000000000000000000DEROMIR 0001000000000000000 "
self.assertEqual(segment.content, response)
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ def testSegmentQsets(self):
segment.setPayerAddress(address)
segment.setGuarantor(guarantor)
response = "3410001300001Q 011000012345678901JOHN SMITH AV PAULISTA 1000 01310000SAO PAULO SP1000009876543210JON SNOW 000 "
self.assertEquals(segment.content, response)
self.assertEqual(segment.content, response)
19 changes: 19 additions & 0 deletions tests/itau/charge/test_slip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from unittest.case import TestCase
from febraban.cnab240.itau.charge import Slip


class SlipTest(TestCase):

def testToString(self):
slip = Slip()
response = """0000001300000P 0100000 000000000000 0109000000000 00000 0000000000000000000000000000099A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0001000000000000000
0000001300000Q 010000000000000000 00000000 0000000000000000 000
0000001300000R 010000000000000000000000000000000000000000000000000 0000000000000000 000000000000 0 """
self.maxDiff = None
self.assertEqual(response, slip.toString().replace('\r', ''))

def testAmount(self):
slip = Slip()
slip.setAmountInCents(100)
amount = slip.amountInCents()
self.assertEqual(amount, 100)
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def testHeaderSets(self):
header = Header()
header.setSender(user)
header.setSenderBank(bank)
response = "34100000 081100012345678901 01234 000001234567 8JOHN SMITH 10312201719400900000000000000 "
self.assertEquals(header.content, response)
response = "34100000 081100012345678901 01234 000001234567 8JOHN SMITH 1 00000000000000 "
self.assertEqual(header.content, response)

def testTrailerSets(self):
trailer = Trailer()
trailer.setSenderBank(bank)
trailer.setNumberOfLotsAndRegisters(num=len([1,2,3]))
trailer.setNumberOfLotsAndRegisters(sum='11', num=len([1,2,3]))
response = "34199999 000003000011 "
self.assertEquals(trailer.content, response)
self.assertEqual(trailer.content, response)
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def testHeaderSets(self):
header.setPositionInLot(2)
header.setInfo(kind="88", method="99")
response = "34100021C8899040 100012345678901 01234 000001234567 8JOHN SMITH AV PAULISTA 1000 SAO PAULO 01310000SP "
self.assertEquals(header.content, response)
self.assertEqual(header.content, response)

def testSegmentASets(self):
segment = SegmentA()
Expand All @@ -73,13 +73,13 @@ def testSegmentASets(self):
segment.setPositionInLot(3)
segment.setScheduleDate("10122017")
segment.setInfo("99")
response = "3410003300001A00000034101234 000001234567 8JOHN SMITH 10122017REA000000000000000000000000044400 00000000000000000000000 0000000001234567890199 "
self.assertEquals(segment.content, response)
response = "3410001300003A00000034101234 000001234567 8JOHN SMITH 10122017REA000000000000000000000000044400 00000000000000000000000 0000000001234567890199 "
self.assertEqual(segment.content, response)

def testTrailerSets(self):
trailer = TrailerLot()
trailer.setAmountInCents(44400)
# trailer.setAmountInCents(44400)
trailer.setSenderBank(bank)
trailer.setPositionInLot(5)
response = "34100055 000003000000000000044400000000000000000000 "
self.assertEquals(trailer.content, response)
response = "34100055 000000000000000000 "
self.assertEqual(trailer.content, response)