Skip to content

Commit

Permalink
Switch to pytest and other test dep updates (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd authored Oct 21, 2024
2 parents d1cdd5f + 3467a4f commit 9bf32e5
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 104 deletions.
21 changes: 0 additions & 21 deletions .circle/circlerc.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .circle/env

This file was deleted.

48 changes: 0 additions & 48 deletions .circle/helpers.sh

This file was deleted.

40 changes: 35 additions & 5 deletions .github/workflows/lint-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ jobs:
strategy:
fail-fast: false
matrix:
version:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v4

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

- name: Clone StackStorm/st2 repo
run: |
Expand All @@ -39,8 +41,36 @@ jobs:
sudo apt-get -y install python3-virtualenv
make requirements
- name: Run lint and tests (Python ${{ matrix.version }})
- name: Run lint and tests (Python ${{ matrix.python-version }})
run: |
make .lint
make .unit-tests
set_merge_ok:
name: Set Merge OK
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
needs:
- build-and-test-python
outputs:
merge_ok: ${{ steps.set_merge_ok.outputs.merge_ok }}
runs-on: ubuntu-latest
steps:
- id: set_merge_ok
run: echo 'merge_ok=true' >> ${GITHUB_OUTPUT}

merge_ok:
name: Merge OK
if: always()
needs:
- set_merge_ok
runs-on: ubuntu-latest
steps:
- run: |
merge_ok="${{ needs.set_merge_ok.outputs.merge_ok }}"
if [[ "${merge_ok}" == "true" ]]; then
echo "Merge OK"
exit 0
else
echo "Merge NOT OK"
exit 1
fi
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ unit-tests: requirements .clone_st2_repo .unit-tests
echo "==========================================================="; \
echo "Running unit tests"; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; nosetests $(NOSE_OPTS) -s -v tests/unit || exit 1; \
. $(VIRTUALENV_DIR)/bin/activate; pytest tests/unit || exit 1; \

.PHONY: .clone_st2_repo
.clone_st2_repo:
Expand Down
7 changes: 1 addition & 6 deletions lint-configs/python/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
[MESSAGES CONTROL]
# C0111 Missing docstring
# I0011 Warning locally suppressed using disable-msg
# I0012 Warning locally suppressed using disable-msg
# W0704 Except doesn't do anything Used when an except clause does nothing but "pass" and there is no "else" clause
# W0142 Used * or * magic* Used when a function or method is called using *args or **kwargs to dispatch arguments.
# W0212 Access to a protected member %s of a client class
# W0232 Class has no __init__ method Used when a class has no __init__ method, neither its parent classes.
# W0613 Unused argument %r Used when a function or method argument is not used.
# W0702 No exception's type specified Used when an except clause doesn't specify exceptions type to catch.
# R0201 Method could be a function
# W0614 Unused import XYZ from wildcard import
# R0914 Too many local variables
# R0912 Too many branches
Expand All @@ -18,7 +13,7 @@
# E0211: Method has no argument
# E1128: Assigning to function call which only returns None Used when an assignment is done on a function call but the inferred function returns nothing but None.
# E1129: Context manager ‘%s’ doesn’t implement __enter__ and __exit__. Used when an instance in a with statement doesn’t implement the context manager protocol(__enter__/__exit__).
disable=C0103,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801,not-context-manager,assignment-from-none
disable=C0103,C0111,I0011,W0212,W0613,W0702,W0614,R0914,R0912,R0915,R0913,R0904,R0801,not-context-manager,assignment-from-none

[TYPECHECK]
# Note: This modules are manipulated during the runtime so we can't detect all the properties during
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
version = parse_version_string(INIT_FILE)
install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='st2-auth-ldap',
version=version,
description='StackStorm authentication backend for LDAP.',
long_description=long_description,
long_description_content_type="text/markdown",
author='StackStorm, Inc.',
author_email='[email protected]',
url='https://stackstorm.com/',
Expand All @@ -46,14 +51,14 @@
"Programming Language :: Python :: 3.11",
'Environment :: Console',
],
python_requires='>=3.8',
platforms=['Any'],
scripts=[],
provides=['st2auth_ldap'],
packages=find_packages(),
include_package_data=True,
install_requires=install_reqs,
dependency_links=dep_links,
test_suite='tests',
entry_points={
'st2auth.backends.backend': [
'ldap = st2auth_ldap.ldap_backend:LDAPAuthenticationBackend',
Expand Down
18 changes: 8 additions & 10 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
unittest2
tox
mock>=1.0
flake8
st2flake8==0.1.0
nose>=1.3.7
isort>=4.2.5,<5
pylint==2.6.0
pylint-plugin-utils>=0.4
coverage
-e git+https://github.com/StackStorm/st2-auth-backend-flat-file.git@master#egg=st2-auth-backend-flat-file
flake8==7.0.0
mock==5.1.0
pylint~=3.1.0
pylint-plugin-utils>=0.4
pytest
st2-auth-backend-flat-file
st2flake8>0.1
tox
4 changes: 2 additions & 2 deletions tests/integration/test_active_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# limitations under the License.

import os
import unittest2
import unittest

from st2auth_ldap import ldap_backend


class ActiveDirectoryAuthenticationTest(unittest2.TestCase):
class ActiveDirectoryAuthenticationTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_openldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# limitations under the License.

import os
import unittest2
import unittest

from st2auth_ldap import ldap_backend


class OpenLDAPAuthenticationTest(unittest2.TestCase):
class OpenLDAPAuthenticationTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import ldap
import mock
import unittest2
import unittest

from st2auth_ldap import ldap_backend

Expand Down Expand Up @@ -82,7 +82,7 @@
]


class LDAPBackendTest(unittest2.TestCase):
class LDAPBackendTest(unittest.TestCase):

def test_instantaite_no_group_dns_provided(self):
# User is member of two of the groups, but none of them are required
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import ldap
import os
import mock
import unittest2
import unittest
import uuid

from st2auth_ldap import ldap_backend
Expand All @@ -36,7 +36,7 @@
LDAP_USER_BAD_PASSWD = 'snow1234'


class LDAPBackendConfigurationTest(unittest2.TestCase):
class LDAPBackendConfigurationTest(unittest.TestCase):

def test_null_bind_dn(self):
self.assertRaises(
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist = py38,py39,py310,py311,lint
[testenv]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = nosetests -sv tests/unit
commands = pytest tests/unit

[testenv:lint]
commands = flake8 --config ./lint-configs/python/.flake8 st2auth_ldap/
Expand Down

0 comments on commit 9bf32e5

Please sign in to comment.