Skip to content

Commit

Permalink
Merge pull request opencord#4 from pherron/master
Browse files Browse the repository at this point in the history
Initial check-in of files for unit test framework for ONU device adapter
  • Loading branch information
pherron27 authored and GitHub Enterprise committed Dec 12, 2018
2 parents 90cea63 + 8fd37cb commit 3b3545b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions voltha/adapters/adtran_onu/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = venv/*, test/*
3 changes: 3 additions & 0 deletions voltha/adapters/adtran_onu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
htmlcov/
venv/
prof/
36 changes: 36 additions & 0 deletions voltha/adapters/adtran_onu/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

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

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) PYTHONPATH=$(PYTHONPATH) py.test -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
3 changes: 0 additions & 3 deletions voltha/adapters/adtran_onu/README.md

This file was deleted.

Empty file.
4 changes: 4 additions & 0 deletions voltha/adapters/adtran_onu/test/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from voltha.adapters.adtran_onu import adtran_onu

def test_example():
assert True
4 changes: 4 additions & 0 deletions voltha/adapters/adtran_onu/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 3b3545b

Please sign in to comment.