Initial commit

This commit is contained in:
Jonas Forsberg 2024-01-11 14:36:01 +00:00
commit 018e7097eb
10 changed files with 265 additions and 0 deletions

141
.gitignore vendored Normal file
View File

@ -0,0 +1,141 @@
# Swap file
*.swp
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2023 $REPO_OWNER
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

33
Makefile Normal file
View File

@ -0,0 +1,33 @@
.PHONY: default install wheel dev test coverage black-check black-diff safety tag
guard-%:
@ if [ "${${*}}" = "" ]; then echo "Run 'pipenv shell' before command"; exit 1; fi
default: test
install: guard-PIPENV_ACTIVE
pip install -e .
wheel: guard-PIPENV_ACTIVE coverage black-check safety
python setup.py bdist_wheel
dev: guard-PIPENV_ACTIVE
pipenv install --dev --skip-lock
test: guard-PIPENV_ACTIVE
PYTHONPATH=./src pytest
coverage: guard-PIPENV_ACTIVE
PYTHONPATH=./src pytest --cov-report term --cov=./src/cli ./tests --cov-report term-missing
black-check: guard-PIPENV_ACTIVE
black --check src/ tests/
black-diff: guard-PIPENV_ACTIVE
black --diff src/ tests/
safety: guard-PIPENV_ACTIVE
pipenv lock --requirements | safety check --stdin
upload: guard-PIPENV_ACTIVE
python3 -m twine upload --repository gitea dist/*

15
Pipfile Normal file
View File

@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pytest = "*"
pytest-mock = "*"
pytest-cov = "*"
black = "*"
safety = "*"
twine = "*"
[requires]
python_version = "3.6"

30
README.rst Normal file
View File

@ -0,0 +1,30 @@
webcheck
===
simple tool to check http(s) response code on remote web service
Preparing for Development
-------------------------
1. Ensure ``pip`` and ``pipenv`` are installed
2. Clone repository: ``git clone https://github.com/SweBarre/sps.git``
3. ``cd`` into repository
4. Activate virtualenv: ``pipenv shell``
5. Fetch development dependencies ``make dev``
Running Tests
-------------
Run tests locally using ``make`` if virtualenv is active:
::
$ make test
If virtualenv isn't active then use:
::
$ pipenv run make

2
setup.cfg Normal file
View File

@ -0,0 +1,2 @@
[bdist_wheel]
python-tag = py36

22
setup.py Normal file
View File

@ -0,0 +1,22 @@
from setuptools import setup, find_packages
from src.cli import __version__ as version
with open("README.rst", encoding="UTF-8") as f:
readme = f.read()
setup(
name="webcheck",
version=version,
description="simple tool to check http(s) response code on remote web service",
long_description=readme,
author="jonas",
author_email="",
packages=find_packages("src"),
package_dir={"": "src"},
install_requires=[],
entry_points={
"console_scripts": [
"webcheck=cli.cli:main",
]
}
)

1
src/cli/__init__.py Normal file
View File

@ -0,0 +1 @@
__version__ = "0.0.1"

3
src/cli/cli.py Normal file
View File

@ -0,0 +1,3 @@
def main():
"""The main program logic"""
print("Hello")

9
tests/test_cli_main.py Normal file
View File

@ -0,0 +1,9 @@
import pytest
from cli import cli
def test_cli_main(capsys):
output = "Hello\n"
cli.main()
captured = capsys.readouterr()
assert captured.out == output