Skip to content

Commit

Permalink
Add pyproject.toml from c-machines
Browse files Browse the repository at this point in the history
Copy the rules which Cockpit-machines enables, except ignore FBT003 for
now and PT as they require more work to fix.
  • Loading branch information
jelly committed Jun 22, 2023
1 parent c9acfcf commit 024aedb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 11 deletions.
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[tool.ruff]
select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"D300", # pydocstyle: Forbid ''' in docstrings
"DTZ", # flake8-datetimez
"E", # pycodestyle
"EXE", # flake8-executable
"F", # pyflakes
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"PLE", # pylint errors
"PGH", # pygrep-hooks
"RSE", # flake8-raise
"RUF", # ruff rules
"T10", # flake8-debugger
"TCH", # flake8-type-checking
"W", # warnings (mostly whitespace)
"YTT", # flake8-2020
]
exclude = [
".git/",
"modules/",
"node_modules/",
]
ignore = [
"A003", # Class attribute is shadowing a python builtin
"B011", # Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
"E731", # Do not assign a `lambda` expression, use a `def`
"FBT002", # Boolean default value in function definition
"FBT003", # Boolean positional value in function call
"PT011", # `pytest.raises(OSError)` is too broad
]
line-length = 118
src = []

[tool.ruff.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false

[tool.ruff.isort]
known-first-party = ["cockpit"]
22 changes: 11 additions & 11 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
# See https://github.com/cockpit-project/cockpit/blob/main/test/common/testlib.py
# "class Browser" and "class MachineCase" for the available API.

import os
import json
import os
import sys

# import Cockpit's machinery for test VMs and its browser test API
TEST_DIR = os.path.dirname(__file__)
sys.path.append(os.path.join(TEST_DIR, "common"))
sys.path.append(os.path.join(os.path.dirname(TEST_DIR), "bots/machine"))

from machine_core import ssh_connection # noqa
import testlib # noqa
import testlib # noqa: E402
from machine_core import ssh_connection # noqa: E402

REGISTRIES_CONF = """
[registries.search]
Expand Down Expand Up @@ -2019,20 +2019,20 @@ class TestApplication(testlib.MachineCase):
b.wait_in_text('#containers-containers .pf-c-empty-state', 'No running containers')
b.wait_in_text('#containers-images .pf-c-empty-state', 'No images')

def check_content(self, type, present, not_present):
def check_content(self, kind, present, not_present):
b = self.browser
for item in present:
b.wait_visible(f'#containers-{type} tbody tr:first-child:contains({item})')
b.wait_visible(f'#containers-{kind} tbody tr:first-child:contains({item})')
for item in not_present:
b.wait_not_present(f'#containers-{type} tbody tr:first-child:contains({item})')
b.wait_not_present(f'#containers-{kind} tbody tr:first-child:contains({item})')

def check_containers(self, present, not_present):
self.check_content("containers", present, not_present)

def check_images(self, present, not_present):
self.check_content("images", present, not_present)

def waitContainer(self, row_id, auth, name="", image="", cmd="", owner="", state=[], pod="no-pod"):
def waitContainer(self, row_id, auth, name="", image="", cmd="", owner="", state=None, pod="no-pod"):
"""Check the container with row_name has the expected values
"image" can be substring, "state" might be string or array of possible states, other are
checked for exact match.
Expand All @@ -2050,7 +2050,7 @@ class TestApplication(testlib.MachineCase):
b.wait_text(sel + " td[data-label=Owner]", owner)
else:
b.wait_text(sel + " td[data-label=Owner]", "user: " + owner)
if state:
if state is not None:
if not isinstance(state, list):
state = [state]
b.wait(lambda: b.text(sel + " td[data-label=State]") in state)
Expand Down Expand Up @@ -2121,7 +2121,7 @@ class TestApplication(testlib.MachineCase):
b.wait_visible("button:contains(Prune unused images).pf-m-disabled")

def testPruneUnusedImagesSystemSelections(self):
''' Test the prune unused images selection options'''
""" Test the prune unused images selection options"""
b = self.browser
self.login(True)

Expand Down Expand Up @@ -2167,7 +2167,7 @@ class TestApplication(testlib.MachineCase):
self._testPruneUnusedContainersSystem(False)

def _testPruneUnusedContainersSystem(self, auth):
'''Test the prune unused container image dialog'''
"""Test the prune unused container image dialog"""

b = self.browser
self.login(auth)
Expand Down Expand Up @@ -2216,7 +2216,7 @@ class TestApplication(testlib.MachineCase):
self.waitPodContainer("pod", pods, auth)

def testCreateContainerValidation(self):
''' Test the validation errors'''
""" Test the validation errors"""
b = self.browser
self.login(False)
container_name = 'portused'
Expand Down

0 comments on commit 024aedb

Please sign in to comment.