Skip to content

Commit

Permalink
Merge pull request #51 from uw-it-aca/task/python-test-matrix
Browse files Browse the repository at this point in the history
add python test matrix, enable deprecation warnings
  • Loading branch information
fanglinfang authored Feb 12, 2024
2 parents e685049 + 2055f0a commit befaa74
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 110 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ name: tests

env:
APP_NAME: uw_pws
COVERAGE_PYTHON_VERSION: '3.10'

on:
push:
Expand All @@ -37,22 +38,29 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'

steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install commonconf nose2 coverage coveralls==2.2.0
pip install commonconf nose2 coverage coveralls==3.3.1
- name: Run Python Linters
uses: uw-it-aca/actions/python-linters@main
Expand All @@ -62,9 +70,10 @@ jobs:
- name: Run Tests
run: |
python -m compileall ${APP_NAME}/
coverage run ${APP_NAME}/test.py -v
python -Wd -m coverage run ${APP_NAME}/test.py -v
- name: Report Test Coverage
if: matrix.python-version == env.COVERAGE_PYTHON_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
Expand All @@ -75,16 +84,16 @@ jobs:

needs: test

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.10'

- name: Publish to PyPi
uses: uw-it-aca/actions/publish-pypi@main
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
name='UW-RestClients-PWS',
version=VERSION,
packages=['uw_pws'],
author="UW-IT AXDD",
author="UW-IT T&LS",
author_email="[email protected]",
include_package_data=True,
install_requires=[
Expand All @@ -38,7 +38,6 @@
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.8',
],
)

Expand Down
2 changes: 1 addition & 1 deletion uw_pws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

"""
Expand Down
2 changes: 1 addition & 1 deletion uw_pws/dao.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

"""
Expand Down
2 changes: 1 addition & 1 deletion uw_pws/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0


Expand Down
2 changes: 1 addition & 1 deletion uw_pws/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from nameparser import HumanName
Expand Down
2 changes: 1 addition & 1 deletion uw_pws/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

# This is just a test runner for coverage
Expand Down
8 changes: 4 additions & 4 deletions uw_pws/tests/test_card.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase
Expand All @@ -14,9 +14,9 @@ class IdCardTestCard(TestCase):
def test_by_rfid(self):
pws = PWS()
person = pws.get_person_by_prox_rfid('1223221621633408')
self.assertEquals(person.uwnetid, 'javerage', "Correct netid")
self.assertEquals(person.uwregid,
'9136CCB8F66711D5BE060004AC494FFE', "Correct regid")
self.assertEqual(person.uwnetid, 'javerage', "Correct netid")
self.assertEqual(person.uwregid,
'9136CCB8F66711D5BE060004AC494FFE', "Correct regid")

# Valid non-existent RFID
self.assertRaises(DataFailureException,
Expand Down
24 changes: 12 additions & 12 deletions uw_pws/tests/test_entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase
Expand Down Expand Up @@ -60,26 +60,26 @@ def test_bad_regids(self):
pws.get_entity_by_regid,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG")

self.assertNotEquals(None,
pws.get_entity_by_regid,
"605764A811A847E690F107D763A4B32A")
self.assertNotEqual(None,
pws.get_entity_by_regid,
"605764A811A847E690F107D763A4B32A")

def _test_regid(self, netid, regid):
pws = PWS()
entity = pws.get_entity_by_regid(regid)

self.assertEquals(entity.uwnetid, netid, netid + "'s netid")
self.assertEquals(entity.uwregid, regid, netid + "'s regid")
self.assertEquals(len(entity.prior_uwnetids), 0)
self.assertEquals(len(entity.prior_uwregids), 0)
self.assertEqual(entity.uwnetid, netid, netid + "'s netid")
self.assertEqual(entity.uwregid, regid, netid + "'s regid")
self.assertEqual(len(entity.prior_uwnetids), 0)
self.assertEqual(len(entity.prior_uwregids), 0)
return entity

def _test_netid(self, netid, regid):
pws = PWS()
entity = pws.get_entity_by_netid(netid)

self.assertEquals(entity.uwnetid, netid, netid + "'s netid")
self.assertEquals(entity.uwregid, regid, netid + "'s regid")
self.assertEquals(len(entity.prior_uwnetids), 0)
self.assertEquals(len(entity.prior_uwregids), 0)
self.assertEqual(entity.uwnetid, netid, netid + "'s netid")
self.assertEqual(entity.uwregid, regid, netid + "'s regid")
self.assertEqual(len(entity.prior_uwnetids), 0)
self.assertEqual(len(entity.prior_uwregids), 0)
return entity
8 changes: 4 additions & 4 deletions uw_pws/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 UW-IT, University of Washington
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

import logging
Expand All @@ -13,7 +13,7 @@ def test_position(self):
"EWPDept": "University of Washington",
"EWPTitle": "Retiree",
"Primary": True})
self.assertEquals(
self.assertEqual(
pos.json_data(),
{'department': "University of Washington",
'title': "Retiree",
Expand Down Expand Up @@ -84,8 +84,8 @@ def test_person(self):
)
self.assertEqual(person.display_name, "Bill Teacher")
self.assertEqual(person.get_formatted_name(), "Bill Teacher")
self.assertEquals(person.employee_state, "current")
self.assertEquals(person.alumni_state, "current")
self.assertEqual(person.employee_state, "current")
self.assertEqual(person.alumni_state, "current")
self.assertTrue(person == person)
self.assertEqual(
person.json_data(),
Expand Down
Loading

0 comments on commit befaa74

Please sign in to comment.