Skip to content

Commit

Permalink
Merge pull request opencord#2 from nstory/master
Browse files Browse the repository at this point in the history
Unit test framework for the OLT adapter
  • Loading branch information
NICOLE STORY authored and GitHub Enterprise committed Dec 11, 2018
2 parents d471fbe + 83a8ff3 commit aaab976
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions voltha/adapters/adtran_olt/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = venv/*, test/*
2 changes: 2 additions & 0 deletions voltha/adapters/adtran_olt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
htmlcov/
venv/
36 changes: 36 additions & 0 deletions voltha/adapters/adtran_olt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
THIS_MAKEFILE := $(abspath $(MAKEFILE_LIST) )
WORKING_DIR := $(dir $(THIS_MAKEFILE) )
ADAPTERS_DIR := $(dir $(patsubst %/,%,$(WORKING_DIR)))
VOLTHA_DIR := $(dir $(patsubst %/,%,$(ADAPTERS_DIR)))

VENVDIR=$(WORKING_DIR)venv
TESTDIR=$(WORKING_DIR)test

ADD_TO_PYTHONPATH := export PYTHONPATH=$(VOLTHA_DIR)/protos/third_party;
IN_VENV=. '$(VENVDIR)/bin/activate'; $(ADD_TO_PYTHONPATH)

PROFILING=--profile-svg
DOT := $(shell command -v dot 2> /dev/null)
ifndef DOT
$(warning "dot is not available please install graphviz")
PROFILING=
endif

RUN_PYTEST=$(IN_VENV) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html

$(VENVDIR):
@virtualenv -p python2 $(VENVDIR)
@virtualenv -p python2 --relocatable $(VENVDIR)

.PHONY: create-venv
create-venv: $(VENVDIR)

.PHONY: test
test: create-venv
@$(IN_VENV) command -v py.test > /dev/null 2>&1 || `echo >&2 "'make requirements' first. Aborting."; exit 1;`
@rm -rf $(TESTDIR)/__pycache__
@cd $(WORKING_DIR) && $(RUN_PYTEST) $(TESTDIR)

.PHONY: requirements
requirements: create-venv
@$(IN_VENV) pip install --upgrade -r test_requirements.txt
Empty file.
4 changes: 4 additions & 0 deletions voltha/adapters/adtran_olt/test/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from voltha.adapters.adtran_olt import adtran_olt

def test_example():
assert True
4 changes: 4 additions & 0 deletions voltha/adapters/adtran_olt/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r ../../../requirements.txt
pytest >= 3.0, < 4.0
pytest-cov >= 2.1.0, < 3.0
pytest-profiling >= 1.1.1, < 2.0

0 comments on commit aaab976

Please sign in to comment.