Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

issue: #7 | PyTest, Makefile & Coverage Report #22

Merged
merged 16 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ venv.bak/
[._]ss[a-gi-z]
[._]sw[a-p]

#IDEs
.vscode

# Session
Session.vim

Expand Down
32 changes: 32 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# variables
COVERAGE_DIR='coverage_data'
TEST_DIR=tests/unit

.PHONY: createVirtualenv
createVirtualenv:
python3 -m pip install --user virtualenv
python3 -m venv env
source env/bin/activate

########
# TEST #
########
.PHONY: preInstall
preInstall:
pip install -U pytest
pytest --version

.PHONY: test
test:
pytest $(TEST_DIR)
@echo 'Tests Completed'

.PHONY: help
help:
@echo 'List all the make tergets available for use with "make list"'

.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
Empty file added tests/__init__.py
Empty file.
Empty file added tests/unit/__init__.py
Empty file.
Empty file added tests/unit/yarpc_py/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions tests/unit/yarpc_py/enums_py/StatusCode_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from yarpc import StatusCode

all_enumaration_types = [
StatusCode.SUCCESS,
StatusCode.BAD_FORMAT,
StatusCode.UNKNOWN_COMMAND,
StatusCode.BAD_PARAMS,
StatusCode.INTERNAL_ERROR,
]


def test_properties_values():
"""
Should ensure that variables are set to their expected values
"""

vals = [0, 1, 2, 3, 4]
for enum in all_enumaration_types:
assert enum.value == vals[enum.value]


def test_properties_types():
"""
Should have the enum variable of type Enum
"""

for enum in all_enumaration_types:
assert type(enum) == StatusCode
Empty file.