chg: added pre-commit fixes on all files that needed them (#31)

This commit is contained in:
Natalia Maximo 2021-07-09 11:04:46 -04:00 коммит произвёл GitHub
Родитель 925e7bd9d6
Коммит e6db097702
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
22 изменённых файлов: 74 добавлений и 77 удалений

Просмотреть файл

@ -17,6 +17,3 @@ repos:
- id: detect-private-key
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: name-tests-test
- id: trailing-whitespace

Просмотреть файл

@ -5,7 +5,7 @@ import re
release_json = sys.argv[1]
platform = sys.argv[2]
asset_regex = re.compile(f"{platform}.tar.gz$")
asset_regex = re.compile(f'{platform}.tar.gz$')
with open(release_json) as f:
release_data = json.load(f)
@ -18,7 +18,7 @@ for data in release_data:
break
if release is None:
print("")
print('')
sys.exit(1)
for asset in release['assets']:

Просмотреть файл

@ -29,10 +29,10 @@ def pytest_load_initial_conftests(early_config: Config, parser: Parser):
return
parser.addoption(
"--quilla-opts",
action="store",
default="",
help="Options to be passed through to the quilla runtime for the scenario tests"
'--quilla-opts',
action='store',
default='',
help='Options to be passed through to the quilla runtime for the scenario tests'
)

Просмотреть файл

@ -25,7 +25,7 @@ def collect_file(parent: pytest.Session, path: LocalPath, prefix: str):
'''
# TODO: change "path" to be "fspath" when pytest 6.3 is released:
# https://docs.pytest.org/en/latest/_modules/_pytest/hookspec.html#pytest_collect_file
if path.ext == ".json" and path.basename.startswith(prefix):
if path.ext == '.json' and path.basename.startswith(prefix):
return QuillaFile.from_parent(parent, fspath=path)

Просмотреть файл

@ -50,11 +50,11 @@ def make_parser() -> argparse.ArgumentParser: # pragma: no cover
parser.add_argument(
'--debug',
action='store_true',
help="Enable debug mode",
help='Enable debug mode',
)
parser.add_argument(
'--driver-dir',
dest="drivers_path",
dest='drivers_path',
action='store',
default='.',
help='The directory where browser drivers are stored',

Просмотреть файл

@ -1,5 +1,5 @@
import quilla # pragma: no cover
if __name__ == "__main__": # pragma: no cover
if __name__ == '__main__': # pragma: no cover
quilla.run()

Просмотреть файл

@ -63,33 +63,33 @@ class UITestActions(Enum):
WAIT_FOR_VISIBILITY = 'WaitForVisibility'
NAVIGATE_TO = 'NavigateTo'
VALIDATE = 'Validate'
REFRESH = "Refresh"
ADD_COOKIES = "AddCookies"
SET_COOKIES = "SetCookies"
REMOVE_COOKIE = "RemoveCookie"
CLEAR_COOKIES = "ClearCookies"
NAVIGATE_FORWARD = "NavigateForward"
NAVIGATE_BACK = "NavigateBack"
SET_BROWSER_SIZE = "SetBrowserSize"
HOVER = "Hover"
OUTPUT_VALUE = "OutputValue"
REFRESH = 'Refresh'
ADD_COOKIES = 'AddCookies'
SET_COOKIES = 'SetCookies'
REMOVE_COOKIE = 'RemoveCookie'
CLEAR_COOKIES = 'ClearCookies'
NAVIGATE_FORWARD = 'NavigateForward'
NAVIGATE_BACK = 'NavigateBack'
SET_BROWSER_SIZE = 'SetBrowserSize'
HOVER = 'Hover'
OUTPUT_VALUE = 'OutputValue'
class ReportType(Enum):
'''
All the currently supported report types
'''
VALIDATION = "Validation"
STEP_FAILURE = "StepFailure"
VALIDATION = 'Validation'
STEP_FAILURE = 'StepFailure'
class BrowserTargets(Enum):
'''
All the currently supported browser targets
'''
FIREFOX = "Firefox"
CHROME = "Chrome"
EDGE = "Edge"
FIREFOX = 'Firefox'
CHROME = 'Chrome'
EDGE = 'Edge'
class OutputSources(Enum):

Просмотреть файл

@ -19,7 +19,7 @@ class NoDriverException(UIValidationException):
'''
def __init__(self):
super().__init__("No driver currently bound")
super().__init__('No driver currently bound')
class FailedStepException(UIValidationException):

Просмотреть файл

@ -55,7 +55,7 @@ class Context(DriverHolder):
logger: A logger instance. If None was passed in for the 'logger' argument, will create
one with the default logger.
'''
default_context: Optional["Context"] = None
default_context: Optional['Context'] = None
_drivers_path: str
_expression_regex = re.compile(r'\${{(.*)}}')
_context_obj_expression = re.compile(
@ -135,7 +135,7 @@ class Context(DriverHolder):
return v
def _set_path(self):
os.environ['PATH'] = f"{self._path}:{self._drivers_path}"
os.environ['PATH'] = f'{self._path}:{self._drivers_path}'
@lru_cache
def perform_replacements(self, text: str) -> str:

Просмотреть файл

@ -23,14 +23,14 @@ class BaseReport(EnumResolver):
msg: A string giving further context to the report
'''
def __init__(self, report_type: ReportType, browser: str, action: UITestActions, msg: str = ""):
def __init__(self, report_type: ReportType, browser: str, action: UITestActions, msg: str = ''):
self.browser: str = browser
self.action: UITestActions = action
self.msg: str = msg
self.report_type: ReportType = report_type
@abstractclassmethod
def from_dict(cls, report: Dict[str, Dict[str, str]]) -> "BaseReport":
def from_dict(cls, report: Dict[str, Dict[str, str]]) -> 'BaseReport':
'''
Converts a dictionary report into a valid Report object
@ -53,7 +53,7 @@ class BaseReport(EnumResolver):
return json.dumps(report)
@classmethod
def from_json(cls, report_json: str) -> "BaseReport":
def from_json(cls, report_json: str) -> 'BaseReport':
'''
Loads a valid json string and attempts to convert it into a Report object
@ -64,7 +64,7 @@ class BaseReport(EnumResolver):
return cls.from_dict(st) # type: ignore
@classmethod
def from_file(cls, fp) -> "BaseReport":
def from_file(cls, fp) -> 'BaseReport':
'''
Converts a fp (a file-like .read() supporting object) containing a json document
into a Report object

Просмотреть файл

@ -108,10 +108,10 @@ class ReportSummary:
For example, to filter by only successful reports you would call
`reports.filter_by.success()`
'''
def __init__(self, summary: "ReportSummary"):
def __init__(self, summary: 'ReportSummary'):
self._summary = summary
def _filter(self, condition: Callable[[BaseReport], bool]) -> "ReportSummary":
def _filter(self, condition: Callable[[BaseReport], bool]) -> 'ReportSummary':
'''
Returns a new summary with only reports that match the condition passed as
a lambda function parameter
@ -121,7 +121,7 @@ class ReportSummary:
return ReportSummary(list(filtered_reports))
def state(self, state: str) -> "ReportSummary":
def state(self, state: str) -> 'ReportSummary':
'''
Returns:
a new summary with only reports that have a state matching the one
@ -131,7 +131,7 @@ class ReportSummary:
lambda x: isinstance(x, ValidationReport) and x.state.lower() == state
)
def browser(self, browser: str) -> "ReportSummary":
def browser(self, browser: str) -> 'ReportSummary':
'''
Returns:
a new summary with only reports that have a browser matching the one
@ -139,21 +139,21 @@ class ReportSummary:
'''
return self._filter(lambda x: x.browser.lower() == browser.lower())
def successful(self) -> "ReportSummary":
def successful(self) -> 'ReportSummary':
'''
Returns:
a new summary with only the reports that produced a success
'''
return self._filter(lambda x: isinstance(x, ValidationReport) and x.success)
def failure(self) -> "ReportSummary":
def failure(self) -> 'ReportSummary':
'''
Returns:
a new summary with only the reports that produced a failure
'''
return self._filter(lambda x: isinstance(x, ValidationReport) and not x.success)
def type(self, validation_type: str) -> "ReportSummary":
def type(self, validation_type: str) -> 'ReportSummary':
'''
Returns:
a new summary with only reports that have a type matching the one
@ -165,7 +165,7 @@ class ReportSummary:
x.validation_type.lower() == validation_type.lower()
)
def target(self, target: str) -> "ReportSummary":
def target(self, target: str) -> 'ReportSummary':
'''
Returns:
a new summary with only reports that have a target matching the one
@ -175,7 +175,7 @@ class ReportSummary:
lambda x: isinstance(x, ValidationReport) and x.target.lower() == target.lower()
)
def critical_failure(self) -> "ReportSummary":
def critical_failure(self) -> 'ReportSummary':
'''
Returns:
a new summary with only reports that constitute a critical failure

Просмотреть файл

@ -32,7 +32,7 @@ class ValidationReport(BaseReport):
state: str,
browser_name: str,
success: bool,
msg: str = ""
msg: str = ''
):
super().__init__(
ReportType.VALIDATION,
@ -46,7 +46,7 @@ class ValidationReport(BaseReport):
self.success = success
@classmethod
def from_dict(cls, report) -> "ValidationReport":
def from_dict(cls, report) -> 'ValidationReport':
'''
Converts a dictionary into a ValidationReport object
@ -54,7 +54,7 @@ class ValidationReport(BaseReport):
report:
'''
params = report['validationReport']
msg = ""
msg = ''
if 'msg' in params:
msg = params['msg']
return ValidationReport(
@ -71,13 +71,13 @@ class ValidationReport(BaseReport):
Returns a dictionary representation of the object
'''
report = {
"validationReport": {
"action": self.action.value,
"type": self.validation_type,
"target": self.target,
"state": self.state,
"targetBrowser": self.browser,
"passed": self.success,
'validationReport': {
'action': self.action.value,
'type': self.validation_type,
'target': self.target,
'state': self.state,
'targetBrowser': self.browser,
'passed': self.success,
}
}

Просмотреть файл

@ -66,7 +66,7 @@ class BaseStep(DriverHolder, EnumResolver):
pass
@abstractmethod
def copy(self) -> "BaseStep":
def copy(self) -> 'BaseStep':
'''
Returns a copy of the current Step object
'''
@ -188,7 +188,7 @@ class BaseValidation(BaseStep):
self._selector = selector
self._report: Optional[ValidationReport] = None
def copy(self) -> "BaseValidation":
def copy(self) -> 'BaseValidation':
# All classes derived from BaseValidation only need these parameters
return self.__class__( # type: ignore
self.ctx, # type: ignore
@ -216,7 +216,7 @@ class BaseValidation(BaseStep):
return self._report
def _create_report(self, success: bool, msg: str = "") -> ValidationReport:
def _create_report(self, success: bool, msg: str = '') -> ValidationReport:
'''
Creates a new validation report. Used to simplify the common shared
behaviour that all validation reports require

Просмотреть файл

@ -29,7 +29,7 @@ class OutputValueStep(BaseStep, BaseStepFactory):
ctx: Context,
action_dict: Dict,
driver: Optional[WebDriver] = None
) -> "BaseStep":
) -> 'BaseStep':
'''
Factory method to extract needed parameters from a dictionary
'''
@ -87,7 +87,7 @@ class OutputValueStep(BaseStep, BaseStepFactory):
return self.element.get_property(property_name)
def copy(self) -> "OutputValueStep":
def copy(self) -> 'OutputValueStep':
'''
Creates a shallow copy of the OutputValueStep object

Просмотреть файл

@ -71,7 +71,7 @@ class TestStep(BaseStep, BaseStepFactory):
ctx: Context,
action_dict,
driver: Optional[WebDriver] = None
) -> "TestStep":
) -> 'TestStep':
'''
Factory method to extract needed parameters from a dictionary
'''
@ -117,7 +117,7 @@ class TestStep(BaseStep, BaseStepFactory):
UITestActions.REMOVE_COOKIE: self._remove_cookie,
}
def copy(self) -> "TestStep":
def copy(self) -> 'TestStep':
'''
Creates a shallow copy of the TestStep object

Просмотреть файл

@ -110,7 +110,7 @@ class StepsAggregator(DriverHolder):
return reports
def copy(self) -> "StepsAggregator":
def copy(self) -> 'StepsAggregator':
'''
Creates a copy of the StepsAggregator object

Просмотреть файл

@ -49,14 +49,14 @@ class QuillaTest(EnumResolver):
}
@classmethod
def from_json(cls, ctx: Context, validation_json: str) -> "QuillaTest": # pragma: no cover
def from_json(cls, ctx: Context, validation_json: str) -> 'QuillaTest': # pragma: no cover
'''
Converts a json string into a UIValidation object
'''
return QuillaTest.from_dict(ctx, json.loads(validation_json))
@classmethod
def from_file(cls, ctx: Context, fp) -> "QuillaTest": # pragma: no cover
def from_file(cls, ctx: Context, fp) -> 'QuillaTest': # pragma: no cover
'''
Converts an fp (a .read() supporting file-like object) containing a json
document into a UIValidation object
@ -64,7 +64,7 @@ class QuillaTest(EnumResolver):
return QuillaTest.from_dict(ctx, json.load(fp))
@classmethod
def from_filename(cls, ctx: Context, path: str) -> "QuillaTest": # pragma: no cover
def from_filename(cls, ctx: Context, path: str) -> 'QuillaTest': # pragma: no cover
'''
Reads a file at the specified path and attempts to convert it into a
UIValidation object
@ -73,7 +73,7 @@ class QuillaTest(EnumResolver):
return QuillaTest.from_file(ctx, fp)
@classmethod
def from_dict(cls, ctx: Context, validation_parameters: dict) -> "QuillaTest":
def from_dict(cls, ctx: Context, validation_parameters: dict) -> 'QuillaTest':
'''
Converts a dictionary that represents a single UIValidation test case into
the appropriate validation object.

Просмотреть файл

@ -46,10 +46,10 @@ def driver():
def pytest_addoption(parser, pluginmanager: PytestPluginManager):
pluginmanager.set_blocked('quilla')
parser.addoption(
"--quilla-opts",
action="store",
default="",
help="Options to be passed through to the quilla runtime for the scenario tests"
'--quilla-opts',
action='store',
default='',
help='Options to be passed through to the quilla runtime for the scenario tests'
)

Просмотреть файл

@ -32,11 +32,11 @@ class UtilTests:
def test_driverholder_returns_expected(self):
holder = DriverHolder()
holder.driver = "Some Value"
holder.driver = 'Some Value'
assert holder.driver == "Some Value"
assert holder.driver == 'Some Value'
@pytest.mark.parametrize("enum_type", [
@pytest.mark.parametrize('enum_type', [
enums.UITestActions,
enums.XPathValidationStates,
enums.URLValidationStates,
@ -49,7 +49,7 @@ class UtilTests:
for val in enum_type:
assert resolver._name_to_enum(val.value, enum_type) is val
@pytest.mark.parametrize("enum_type", [
@pytest.mark.parametrize('enum_type', [
enums.UITestActions,
enums.XPathValidationStates,
enums.URLValidationStates,