Skip to content

Commit

Permalink
fmt: automated source code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Dec 30, 2020
1 parent 0760215 commit ade3f4e
Show file tree
Hide file tree
Showing 80 changed files with 1,123 additions and 1,203 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
python -m pip install -U pip setuptools wheel
python -m pip install -U tox tox-gh-actions
- name: Lint
run: tox -e lint
run: tox -e lint
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
python -m pip install -U pip setuptools wheel
python -m pip install -U tox tox-gh-actions
- name: Run tests
run: tox
run: tox
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ venv.bak/
.idea

# Local configuration files
.local
.local
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
66 changes: 33 additions & 33 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@

# -- Path setup --------------------------------------------------------------

import datetime
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from kubetest import __version__
import os
import sys
import datetime

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath("."))


# -- Project information -----------------------------------------------------

project = 'kubetest'
project = "kubetest"
year = datetime.datetime.now().year
copyright = '2018, Vapor IO'
author = 'Vapor IO'
copyright = "2018, Vapor IO"
author = "Vapor IO"

# The short X.Y version
version = __version__
Expand All @@ -44,22 +45,22 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -71,18 +72,18 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'friendly'
pygments_style = "friendly"


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -93,7 +94,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand All @@ -109,7 +110,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'kubetestdoc'
htmlhelp_basename = "kubetestdoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -118,15 +119,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -136,19 +134,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'kubetest.tex', 'kubetest Documentation',
'Vapor IO', 'manual'),
(master_doc, "kubetest.tex", "kubetest Documentation", "Vapor IO", "manual"),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'kubetest', 'kubetest Documentation',
[author], 1)
]
man_pages = [(master_doc, "kubetest", "kubetest Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -157,9 +151,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'kubetest', 'kubetest Documentation',
author, 'kubetest', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"kubetest",
"kubetest Documentation",
author,
"kubetest",
"One line description of project.",
"Miscellaneous",
),
]


Expand All @@ -178,13 +178,13 @@
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]


# -- Extension configuration -------------------------------------------------

# Autodoc
autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"

# Configure the Napoleon extension for Google style docstrings
napoleon_google_docstring = True
Expand Down
1 change: 0 additions & 1 deletion docs/markers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,3 @@ Examples
@pytest.mark.namespace(create=True, name='specific-name')
def test_something(kube):
...
2 changes: 1 addition & 1 deletion docs/module_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Below is a complete module reference
.. toctree::
:maxdepth: 4

source/modules
source/modules
2 changes: 1 addition & 1 deletion docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ Helpers

.. autofunction:: kubetest.condition.check_all

.. autofunction:: kubetest.condition.check_and_sort
.. autofunction:: kubetest.condition.check_and_sort
15 changes: 7 additions & 8 deletions docs/writing_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ you can access it from wherever the tests are being run.
Cluster Configuration
---------------------

By default, kubetest will look for a config file at ``~/.kube/config`` and the
current context -- this is the same behavior that ``kubectl`` utilizes for the
resolving cluster config. Generally, if you can reach your cluster via.
By default, kubetest will look for a config file at ``~/.kube/config`` and the
current context -- this is the same behavior that ``kubectl`` utilizes for the
resolving cluster config. Generally, if you can reach your cluster via.
``kubectl``, you should be able to use it with kubetest.

If you wish to specify a different config file and/or context, you can pass it
If you wish to specify a different config file and/or context, you can pass it
in via the ``--kube-config`` and ``--kube-context`` flags.
See :ref:`command_line_usage` for more details.

You can also write a ``kubeconfig`` fixture which provides the path to the
config file and/or a ``kubecontext`` fixture which provides the name of the
context to be used. This may be useful in case your cluster is generated as
config file and/or a ``kubecontext`` fixture which provides the name of the
context to be used. This may be useful in case your cluster is generated as
part of the tests or you wish to use specific contexts in different parts of
the suite.

Expand All @@ -39,7 +39,7 @@ the suite.
# at somepath
subprocess.check_call(['terraform', 'apply'])
return 'somepath/kubeconfig'
@pytest.fixture
def kubecontext() -> Optional[str]:
Expand Down Expand Up @@ -247,4 +247,3 @@ Wait until a Pod's containers have all started.
pods = kube.get_pods()
for pod in pods.values():
pod.wait_until_containers_start(timeout=60)
2 changes: 1 addition & 1 deletion examples/configs/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ spec:
- path: /
backend:
serviceName: my-service
servicePort: 80
servicePort: 80
2 changes: 1 addition & 1 deletion examples/configs/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: build-robot
automountServiceAccountToken: false
automountServiceAccountToken: false
4 changes: 2 additions & 2 deletions examples/get-all-pods-via-fixture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kubetest config file: ./config
kubetest context: current context
rootdir: /Users/edaniszewski/dev/vaporio/kubetest
plugins: asyncio-0.10.0, kubetest-0.1.0
collected 5 items
collected 5 items

test_examples.py ..... [100%]

Expand All @@ -36,4 +36,4 @@ test_examples.py .....
```

> Note: The `--suppress-insecure-request` seen above is to suppress warnings generated
> when running tests on a cluster without SSL enabled (e.g. a local cluster).
> when running tests on a cluster without SSL enabled (e.g. a local cluster).
1 change: 0 additions & 1 deletion examples/get-all-pods-via-fixture/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import pytest


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ spec:
# line below:
# value: env
ports:
- containerPort: 80
- containerPort: 80
46 changes: 27 additions & 19 deletions examples/get-all-pods-via-fixture/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import time

import pytest
import time
import os


@pytest.mark.applymanifest(os.path.join(os.path.dirname(__file__),
'manifests/deployment-redis.yaml'))
@pytest.mark.applymanifest(
os.path.join(os.path.dirname(__file__), "manifests/deployment-redis.yaml")
)
def test_pods_from_deployment_loaded_from_marker(kube):
"""Get the Pods for a Deployment which is loaded via the kubetest
'applymanifest' marker.
Expand All @@ -26,8 +27,8 @@ def test_pods_from_deployment_loaded_from_marker(kube):
# Get the redis-master deployment. The `deployments` response is a
# dict where the key is the name for the object (e.g. as defined in
# the manifest), and the value is the corresponding Deployment object.
assert 'redis-master' in deployments
redis_master = deployments['redis-master']
assert "redis-master" in deployments
redis_master = deployments["redis-master"]

# Get the pods for the deployment. Since the deployment is defined
# as having one replica, we expect to only get back one pod.
Expand All @@ -44,8 +45,9 @@ def test_pods_from_deployment_loaded_in_test_case(kube):
use that to get the pods for the deployment.
"""

deployment = kube.load_deployment(os.path.join(
os.path.dirname(__file__), 'manifests/deployment-redis.yaml'))
deployment = kube.load_deployment(
os.path.join(os.path.dirname(__file__), "manifests/deployment-redis.yaml")
)
deployment.create()
deployment.wait_until_ready(timeout=30)

Expand All @@ -56,10 +58,13 @@ def test_pods_from_deployment_loaded_in_test_case(kube):
assert len(pods) == 1


@pytest.mark.applymanifests('manifests', files=[
'deployment-redis.yaml',
'deployment-frontend.yaml',
])
@pytest.mark.applymanifests(
"manifests",
files=[
"deployment-redis.yaml",
"deployment-frontend.yaml",
],
)
def test_all_pods_for_test_namespace(kube):
"""Get all of the Pods within the test namespace.
Expand Down Expand Up @@ -93,14 +98,17 @@ def test_all_pods_for_other_namespace(kube):
# Get the pods belonging to the kube-system namespace. Since this
# is running on a Kubernetes cluster, there should be some pods in
# this namespace.
pods = kube.get_pods(namespace='kube-system')
pods = kube.get_pods(namespace="kube-system")
assert len(pods) > 0


@pytest.mark.applymanifests('manifests', files=[
'deployment-redis.yaml',
'deployment-frontend.yaml',
])
@pytest.mark.applymanifests(
"manifests",
files=[
"deployment-redis.yaml",
"deployment-frontend.yaml",
],
)
def test_all_pods_via_custom_fixture(kube, custom_pods):
"""Get all of the Pods with a custom fixture.
Expand All @@ -127,9 +135,9 @@ def test_all_pods_via_custom_fixture(kube, custom_pods):
count_master = 0

for pod_name in custom_pods:
if 'frontend' in pod_name:
if "frontend" in pod_name:
count_frontend += 1
if 'redis-master' in pod_name:
if "redis-master" in pod_name:
count_master += 1

assert count_frontend == 3
Expand Down
Loading

0 comments on commit ade3f4e

Please sign in to comment.