Skip to content
Permalink
Browse files

tests: add package tests

Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
  • Loading branch information...
fscherf committed Oct 15, 2019
1 parent a4d5f1e commit 197db903b327ebe9521d4555e637bc620b80ba24
Showing with 87 additions and 3 deletions.
  1. +11 −2 Makefile
  2. +1 −0 REQUIREMENTS.dev.txt
  3. +75 −1 tests/test_package.py
@@ -13,13 +13,18 @@ env: $(PYTHON_VENV)/.created
clean:
rm -rf $(PYTHON_VENV)

lazy-test: env
. $(PYTHON_VENV)/bin/activate && \
tox $(args)

test: env
. $(PYTHON_VENV)/bin/activate && \
tox
rm -rf flamingo.egg-info dist build && \
tox -r $(args)

ci-test: env
. $(PYTHON_VENV)/bin/activate && \
JENKINS_URL=1 tox
JENKINS_URL=1 tox -r $(args)

edit: env
. $(PYTHON_VENV)/bin/activate && \
@@ -41,3 +46,7 @@ test-site: env
server: test-site
cd test-site && \
make server

check-manifest: env
. $(PYTHON_VENV)/bin/activate && \
check-manifest --ignore "flamingo-web.org/*,tests/*,*.swp,.*"
@@ -1,3 +1,4 @@
-e .[full]
tox
flake8
check-manifest
@@ -1,2 +1,76 @@
def test_package():
def find_source_files(path):
import os

source_files = []

for root, dirs, files in os.walk(path):
if '__pycache__' in root:
continue

for name in files:
if name.startswith('.') or '~' in name or '#' in name:
continue

extension = os.path.splitext(name)[1]

if extension in ('.swp', '.pyc', ):
continue

source_files.append(
os.path.join(
'flamingo',
os.path.relpath(os.path.join(root, name), path),
)
)

return set(source_files)


def test_imports():
"""
This test checks if flamingo is importable.
"""

import flamingo # NOQA


def test_package_data():
"""
This test checks if all source code files in flamingo/ were rolled out to
the test environment.
"""

import os

import flamingo

source_files = find_source_files(os.path.join(os.getcwd(), 'flamingo'))
package_files = find_source_files(os.path.dirname(flamingo.__file__))

assert source_files == package_files


def test_vcs():
"""
This test checks if all source code files in flamingo/ are part of the vcs.
"""

from subprocess import check_output
import os

import pytest

try:
check_output(['git', 'status'])

except Exception:
pytest.skip('git is not available')

source_files = find_source_files(os.path.join(os.getcwd(), 'flamingo'))

vcs_source_files = set([
i for i in check_output(['git', 'ls-files']).decode().splitlines()
if i.startswith('flamingo/')
])

assert source_files == vcs_source_files

0 comments on commit 197db90

Please sign in to comment.
You can’t perform that action at this time.