Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Feature/static tests (#7)
Browse files Browse the repository at this point in the history
* add flake8 to tox #1
  • Loading branch information
nolte committed Jan 7, 2019
1 parent 6d05010 commit ee30dde
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 27 deletions.
29 changes: 24 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ jobs:
- *run_task_add_gh_known_hosts
- *run_task_push_github_page

statictests:
<<: *container_python
working_directory: /tmp/workspaces/build
steps:
- attach_workspace:
at: /tmp/workspaces
- *run_task_install_tox_dependencies
- run:
name: execute the flake8 static tests
command: |
tox -e flake8
- store_test_results:
path: .tox/test/tmp/reports
testing:
<<: *container_python
working_directory: /tmp/workspaces/build
Expand Down Expand Up @@ -322,24 +335,30 @@ workflows:
execute_smoke_test:
jobs:
- check_grade_up_build
- execute_integration_tests:
- statictests:
requires:
- check_grade_up_build
- execute_integration_tests:
requires:
- statictests
- builddocs:
requires:
- check_grade_up_build
- statictests
- testing:
requires:
- check_grade_up_build
- statictests
build_and_test:
jobs:
- check_grade_up_build
- builddocs:
- statictests:
requires:
- check_grade_up_build
- builddocs:
requires:
- statictests
- testing:
requires:
- check_grade_up_build
- statictests
- publishghpage:
requires:
- builddocs
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
matrix:
- SCENARIO_NAME=docs
- SCENARIO_NAME=test
- SCENARIO_NAME=flake8
install:
- pip install tox-travis
script:
Expand Down
7 changes: 1 addition & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import sys
import os
import shlex


extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
Expand All @@ -26,7 +21,7 @@
source_suffix = ['.rst', '.md']

# The encoding of source files.
#source_encoding = 'utf-8-sig'
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
Expand Down
3 changes: 3 additions & 0 deletions docs/development/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Testing
Static tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For the Static Tests we use `flake8 <http://flake8.pycqa.org/en/latest/>`_, this will check the style.
The cofiguration can found at the `tox.ini`

.. _development-process-test-unit:

Unit tests
Expand Down
4 changes: 3 additions & 1 deletion it-tests/test_smoke_deployment.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import pytest
import sys, os
import os


@pytest.fixture
def chrome_options(chrome_options):
chrome_options.add_argument('headless')
return chrome_options


def test_example(selenium):
selenium.get(os.environ["SELENIUM_BASE_URL"])
# selenium.save_screenshot('/tmp/screenshot/sample_screenshot_1.png');
Expand Down
29 changes: 16 additions & 13 deletions tests/test_minimal_template.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
import filecmp


def test_bake_project(cookies):
result = cookies.bake(extra_context={'project_slug': 'simple'})
verfiy_base_project_attributes(result,'simple')

verfiy_base_project_attributes(result, 'simple')


def test_bake_project_with_tox_ini(cookies):
result = cookies.bake(extra_context={'project_slug': 'simplewithtox','generate_tox_file': 'y' })
verfiy_base_project_attributes(result,'simplewithtox')
testconfig = {'project_slug': 'simplewithtox', 'generate_tox_file': 'y'}
result = cookies.bake(extra_context=testconfig)
verfiy_base_project_attributes(result, 'simplewithtox')
tox_file = result.project.join('tox.ini')
assert filecmp.cmp(str(tox_file), 'tests/golden_files/minimal/tox.ini',shallow=0)
assert filecmp.cmp(str(tox_file), 'tests/golden_files/minimal/tox.ini', shallow=0)
assert result.project.join('docsRequirements.txt').check(exists=0)

circleci_job_file = result.project.join('.circleci/config.yml');
circleci_job_file = result.project.join('.circleci/config.yml')
assert circleci_job_file.isfile()
assert filecmp.cmp(str(circleci_job_file), 'tests/golden_files/minimal/config.yml',shallow=0)
assert filecmp.cmp(str(circleci_job_file), 'tests/golden_files/minimal/config.yml', shallow=0)


def test_bake_project_with_tox_ini_and_sphinx(cookies):
result = cookies.bake(extra_context={'project_slug': 'simplewithtox','generate_tox_file': 'y','generate_sphinx_doc': 'y' })
verfiy_base_project_attributes(result,'simplewithtox')
testconfig = {'project_slug': 'simplewithtox', 'generate_tox_file': 'y', 'generate_sphinx_doc': 'y'}
result = cookies.bake(extra_context=testconfig)
verfiy_base_project_attributes(result, 'simplewithtox')
tox_file = result.project.join('tox.ini')

assert tox_file.isfile()
assert filecmp.cmp(str(tox_file), 'tests/golden_files/sphinx/tox.ini',shallow=0)
circleci_job_file = result.project.join('.circleci/config.yml');
assert filecmp.cmp(str(tox_file), 'tests/golden_files/sphinx/tox.ini', shallow=0)
circleci_job_file = result.project.join('.circleci/config.yml')
assert circleci_job_file.isfile()
assert filecmp.cmp(str(circleci_job_file), 'tests/golden_files/sphinx/config.yml',shallow=0)
assert filecmp.cmp(str(circleci_job_file), 'tests/golden_files/sphinx/config.yml', shallow=0)
assert result.project.join('docsRequirements.txt').check(exists=1)

def verfiy_base_project_attributes(result,expectedProjectName):

def verfiy_base_project_attributes(result, expectedProjectName):
assert result.exit_code == 0
assert result.exception is None
assert result.project.basename == expectedProjectName
Expand Down
15 changes: 13 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# content of: tox.ini , put in same dir as setup.py
# configuration for flake8
[flake8]
max-line-length = 180
exclude = .venv,.tox,dist,doc,build,*.egg


[tox]
envlist =
{py27,py36}-{test},docs,{py36}-{github,readthedocs-latest,readthedocs-stable}-{integrationtests}
flake8,{py27,py36}-{test},docs,{py36}-{github,readthedocs-latest,readthedocs-stable}-{integrationtests}
skipsdist=True

[testenv]
Expand All @@ -23,6 +28,12 @@ deps=
commands=
bumpversion --commit release

[testenv:flake8]
deps =
flake8==3.6.0
commands =
flake8 {toxinidir}

[testenv:deviteration]
deps=
bumpversion
Expand Down

0 comments on commit ee30dde

Please sign in to comment.