Skip to content

Commit

Permalink
adding logic to handle github report format (#36)
Browse files Browse the repository at this point in the history
* adding logic to handle github format

* Bump 2022.3.1 to 2022.6.0

* adding new report test
  • Loading branch information
fdosani authored Jun 22, 2022
1 parent 181fbef commit fdde109
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
author = "Akshay Gupta"

# The short X.Y version
version = "2022.4.0"
version = "2022.6.0"
# The full version, including alpha/beta/rc tags
release = ""

Expand Down
2 changes: 1 addition & 1 deletion edgetest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Package initialization."""


__version__ = "2022.4.0"
__version__ = "2022.6.0"

__title__ = "edgetest"
__description__ = "Bleeding edge dependency testing"
Expand Down
12 changes: 10 additions & 2 deletions edgetest/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@

from .core import TestPackage

VALID_OUTPUTS = ["rst", "github"]

def gen_report(testers: List[TestPackage]) -> Any:

def gen_report(testers: List[TestPackage], output_type: str = "rst") -> Any:
"""Generate a rST report.
Parameters
----------
testers : list
A list of ``TestPackage`` objects.
output_type : str
A valid output type of ``rst`` or ``github``
Returns
-------
Any
The report.
"""
if output_type not in VALID_OUTPUTS:
raise ValueError(f"Invalid output_type provided: {output_type}")

headers = ["Environment", "Passing tests", "Upgraded packages", "Package version"]
rows: List[List] = []
for env in testers:
upgraded = env.upgraded_packages()
for pkg in upgraded:
rows.append([env.envname, env.status, pkg["name"], pkg["version"]])

return tabulate(rows, headers=headers, tablefmt="rst")
return tabulate(rows, headers=headers, tablefmt=output_type)
37 changes: 18 additions & 19 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ license = Apache Software License
maintainer = Akshay Gupta
maintainer_email = akshay.gupta2@capitalone.com
url = https://github.com/capitalone/edgetest
python_requires =
python_requires =
>=3.7.0
project_urls =
project_urls =
Documentation = https://capitalone.github.io/edgetest/
Bug Tracker = https://github.com/capitalone/edgetest/issues
Source Code = https://github.com/capitalone/edgetest
classifiers =
classifiers =
Intended Audience :: Developers
Natural Language :: English
Operating System :: OS Independent
Expand All @@ -31,29 +31,29 @@ classifiers =
zip_safe = False
include_package_data = True
packages = find:
install_requires =
install_requires =
Cerberus<=1.3.4,>=1.3.0
click<=8.1.3,>=7.0
pluggy<=1.0.0,>=1.0.0
tabulate<=0.8.9,>=0.8.9
packaging<=21.3,>20.6

[options.extras_require]
docs =
docs =
furo
sphinx
sphinx-copybutton
sphinx-tabs
pillow
recommonmark
tests =
tests =
coverage
flake8
mypy
pydocstyle
pytest
pytest-cov
qa =
qa =
pylint
pip-tools
pre-commit
Expand All @@ -62,12 +62,12 @@ qa =
types-click
types-pkg_resources
types-tabulate
build =
build =
build
twine
wheel
bumpver
dev =
dev =
coverage
flake8
mypy
Expand All @@ -94,21 +94,21 @@ dev =
bumpver

[options.entry_points]
console_scripts =
console_scripts =
edgetest = edgetest.interface:cli

[bumpver]
current_version = "2022.3.1"
current_version = "2022.6.0"
version_pattern = "YYYY.MM.INC0"
commit_message = "Bump {old_version} to {new_version}"
commit = True

[bumpver:file_patterns]
docs/source/conf.py =
docs/source/conf.py =
version = "{version}"
setup.cfg =
setup.cfg =
current_version = "{version}"
edgetest/__init__.py =
edgetest/__init__.py =
__version__ = "{version}"

[aliases]
Expand Down Expand Up @@ -141,21 +141,20 @@ allow_redefinition = True
pylint_minimum_score = 9.5

[tool:pytest]
markers =
markers =
unit: mark unit tests that do not require external interfaces and use mocking
integration: mark test that interact with an external system
addopts = --verbose

[edgetest.envs.core]
python_version = 3.9
upgrade =
upgrade =
Cerberus
click
pluggy
tabulate
packaging
extras =
extras =
tests
deps =
deps =
pip-tools

43 changes: 43 additions & 0 deletions tests/test_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from unittest.mock import patch

import pytest

from edgetest.core import TestPackage
from edgetest.report import gen_report


@patch("edgetest.report.tabulate", autospec=True)
@patch("edgetest.core.TestPackage.upgraded_packages", autospec=True)
def test_report(mock_test_package, mock_tabulate, plugin_manager):
"""Test gen_report function"""

tester_list = [
TestPackage(hook=plugin_manager.hook, envname="myenv", upgrade=["myupgrade1"]),
TestPackage(hook=plugin_manager.hook, envname="myenv", upgrade=["myupgrade2"]),
]
gen_report(tester_list)
mock_tabulate.assert_called_with(
[],
headers=[
"Environment",
"Passing tests",
"Upgraded packages",
"Package version",
],
tablefmt="rst",
)

gen_report(tester_list, output_type="github")
mock_tabulate.assert_called_with(
[],
headers=[
"Environment",
"Passing tests",
"Upgraded packages",
"Package version",
],
tablefmt="github",
)

with pytest.raises(ValueError) as e:
gen_report(tester_list, output_type="bad")

0 comments on commit fdde109

Please sign in to comment.