Skip to content

Commit

Permalink
Added support for running tests via Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Shariq Torres committed Dec 20, 2021
1 parent 6ecdf1e commit 2d7031c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[run]
source=lob
[report]
exclude_lines =
# Have to re-enable the standard pragma
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ jobs:
cache: 'pipenv'
- run: pip install pipenv
- run: pipenv sync --dev
- run: pip install pytest
- run: pip install requests
- run: pytest ./tests/test_check.py
- run: pipenv run tests
env:
LOB_API_KEY: ${{ secrets.LOB_API_KEY }}
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
11 changes: 6 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ requests = "*"

[dev-packages]
"flake8" = "*"
coverage = "*"
coveralls = "*"
coverage = "5.5"
coveralls = "2.2.0"
bumpversion = "*"
setuptools = "*"
twine = "*"
pytest = "*"
pytest-cov = "*"
pytest = "6.2.1"
pytest-cov = "2.11.1"

[scripts]
# these commands can be invoked with `pipenv run <script_name>`
tests = "pytest --cov=lob"
tests = "pytest --cov"
coveralls = "coveralls --service=github.com"
44 changes: 27 additions & 17 deletions tests/test_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ class TestAddressFunctions(unittest.TestCase):
def setUp(self):
lob.api_key = os.environ.get('LOB_API_KEY')


def test_create_address(self):
address = lob.Address.create(
name='Lob',
address_line1='185 Berry Street',
address_line2='Suite 1510',
address_city='San Francisco',
address_zip='94017',
address_state='CA',
address_country='US'
)

self.assertTrue(isinstance(address, lob.Address))
self.assertEqual(address.name, 'LOB')

def test_list_addresses(self):
addresses = lob.Address.list()
self.assertTrue(isinstance(addresses.data[0], lob.Address))
Expand All @@ -28,20 +43,6 @@ def test_list_address_fail(self):
with pytest.raises(lob.error.InvalidRequestError):
lob.Address.list(foobar=1000)

def test_create_address(self):
address = lob.Address.create(
name='Lob',
address_line1='185 Berry Street',
address_line2='Suite 1510',
address_city='San Francisco',
address_zip='94017',
address_state='CA',
address_country='US'
)

self.assertTrue(isinstance(address, lob.Address))
self.assertEqual(address.name, 'LOB')

def test_create_addresss_fail(self):
self.assertRaises(lob.error.InvalidRequestError, lob.Address.create)

Expand All @@ -53,6 +54,15 @@ def test_retrieve_address_fail(self):
self.assertRaises(lob.error.InvalidRequestError, lob.Address.retrieve, id='test')

def test_delete_address(self):
addr = lob.Address.list().data[0].id
delAddr = lob.Address.delete(id=addr)
self.assertEqual(addr, delAddr.id)
address = lob.Address.create(
name='Lob',
address_line1='185 Berry Street',
address_line2='Suite 1510',
address_city='San Francisco',
address_zip='94017',
address_state='CA',
address_country='US'
)

delAddr = lob.Address.delete(id=address.id)
self.assertEqual(address.id, delAddr.id)

0 comments on commit 2d7031c

Please sign in to comment.