Skip to content

Commit

Permalink
[cdd/tests/test_sqlalchemy/test_parse_sqlalchemy_utils.py] Increase t…
Browse files Browse the repository at this point in the history
…est coverage ; [cdd/__init__.py] Bump version ; [.github/workflows/main.yml] Test coverage for 3.6 also ; use `python -m pip` everywhere over `pip`
  • Loading branch information
SamuelMarks committed Mar 15, 2024
1 parent 8d83ccb commit c4fe8e2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
pip install -r requirements.txt
python -m pip install -r requirements.txt
- name: Test with unittest
run: |
python setup.py test
- name: Test coverage
run: |
python -m pip install codecov coverage
coverage run -m unittest discover
env
bash <(curl --proto '=https' --tlsv1.2 -sSf https://codecov.io/bash)
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
test:
name: ${{ matrix.os.name }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os.runs-on }}
Expand Down Expand Up @@ -68,24 +77,24 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
pip install -r requirements.txt
python -m pip install -r requirements.txt
- name: Test with unittest
run: |
python setup.py test
- name: Lint with flake8
run: |
pip install flake8
python -m pip install flake8
flake8 . --count --select=$(printf '%s,' {A..Z}) --ignore='F811,W503,E203' --show-source --max-complexity=13 --max-line-length=119 --statistics
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: Check formatted with black
run: |
pip install black
python -m pip install black
python -m black . --check --extend-exclude 'cdd/tests/mocks/cstify.py'
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: Doc coverage
run: |
pip install interrogate
python -m pip install interrogate
interrogate -e 'cdd/tests/mocks/cstify.py' --generate-badge '.github/doccoverage.svg'
sed -i 's/interrogate/doc coverage/g; s/data-doc c/data-doc-c/g' .github/doccoverage.svg
# Setup git config
Expand All @@ -103,7 +112,7 @@ jobs:
if: matrix.python-version == '3.8' && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: Test coverage
run: |
pip install codecov coverage
python -m pip install codecov coverage
coverage run -m unittest discover
env
bash <(curl --proto '=https' --tlsv1.2 -sSf https://codecov.io/bash)
Expand All @@ -112,7 +121,7 @@ jobs:
if: (matrix.python-version == '3.8' || matrix.python-version == '3.12') && matrix.os.name == 'Linux' && github.ref == 'refs/heads/master'
- name: PyPi release
run: |
pip install twine
python -m pip install twine
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
env:
Expand Down
2 changes: 1 addition & 1 deletion cdd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from logging import getLogger as get_logger

__author__ = "Samuel Marks" # type: str
__version__ = "0.0.99rc35" # type: str
__version__ = "0.0.99rc36" # type: str
__description__ = (
"Open API to/fro routes, models, and tests. "
"Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy."
Expand Down
22 changes: 22 additions & 0 deletions cdd/tests/test_sqlalchemy/test_parse_sqlalchemy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from unittest import TestCase

from cdd.shared.ast_utils import set_value
from cdd.shared.pure_utils import pp
from cdd.sqlalchemy.utils.parse_utils import (
column_call_name_manipulator,
column_call_to_param,
Expand Down Expand Up @@ -88,6 +89,27 @@ def test_column_call_to_param_fk(self) -> None:
self.assertEqual(gold_name, gen_name)
self.assertDictEqual(gold_param, gen_param)

def test_column_call_to_param_from_ast_construct(self) -> None:
"""
Tests that `parse.sqlalchemy.utils.column_call_to_param` works with AST construct
"""
node_with_func_call = deepcopy(node_fk_call)
node_with_func_call.args[-1].func.id = "Foo"
gen_name, gen_param = column_call_to_param(node_with_func_call)
gold_name, gold_param = (
lambda _name: (
_name,
{
"x_typ": deepcopy(
intermediate_repr_node_pk["params"][_name]["x_typ"]
),
"typ": "Foo('element.element_id')",
},
)
)("primary_element")
self.assertEqual(gold_name, gen_name)
self.assertDictEqual(gold_param, gen_param)

def test_get_pk_and_type(self) -> None:
"""
Tests get_pk_and_type
Expand Down

0 comments on commit c4fe8e2

Please sign in to comment.