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: detect-private-key
- id: double-quote-string-fixer - id: double-quote-string-fixer
- id: end-of-file-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] release_json = sys.argv[1]
platform = sys.argv[2] 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: with open(release_json) as f:
release_data = json.load(f) release_data = json.load(f)
@ -18,7 +18,7 @@ for data in release_data:
break break
if release is None: if release is None:
print("") print('')
sys.exit(1) sys.exit(1)
for asset in release['assets']: for asset in release['assets']:

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

@ -29,10 +29,10 @@ def pytest_load_initial_conftests(early_config: Config, parser: Parser):
return return
parser.addoption( parser.addoption(
"--quilla-opts", '--quilla-opts',
action="store", action='store',
default="", default='',
help="Options to be passed through to the quilla runtime for the scenario tests" 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: # 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 # 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) return QuillaFile.from_parent(parent, fspath=path)

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

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

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

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

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

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

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

@ -19,7 +19,7 @@ class NoDriverException(UIValidationException):
''' '''
def __init__(self): def __init__(self):
super().__init__("No driver currently bound") super().__init__('No driver currently bound')
class FailedStepException(UIValidationException): 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 logger: A logger instance. If None was passed in for the 'logger' argument, will create
one with the default logger. one with the default logger.
''' '''
default_context: Optional["Context"] = None default_context: Optional['Context'] = None
_drivers_path: str _drivers_path: str
_expression_regex = re.compile(r'\${{(.*)}}') _expression_regex = re.compile(r'\${{(.*)}}')
_context_obj_expression = re.compile( _context_obj_expression = re.compile(
@ -135,7 +135,7 @@ class Context(DriverHolder):
return v return v
def _set_path(self): def _set_path(self):
os.environ['PATH'] = f"{self._path}:{self._drivers_path}" os.environ['PATH'] = f'{self._path}:{self._drivers_path}'
@lru_cache @lru_cache
def perform_replacements(self, text: str) -> str: def perform_replacements(self, text: str) -> str:

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

@ -23,14 +23,14 @@ class BaseReport(EnumResolver):
msg: A string giving further context to the report 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.browser: str = browser
self.action: UITestActions = action self.action: UITestActions = action
self.msg: str = msg self.msg: str = msg
self.report_type: ReportType = report_type self.report_type: ReportType = report_type
@abstractclassmethod @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 Converts a dictionary report into a valid Report object
@ -53,7 +53,7 @@ class BaseReport(EnumResolver):
return json.dumps(report) return json.dumps(report)
@classmethod @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 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 return cls.from_dict(st) # type: ignore
@classmethod @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 Converts a fp (a file-like .read() supporting object) containing a json document
into a Report object into a Report object

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -49,14 +49,14 @@ class QuillaTest(EnumResolver):
} }
@classmethod @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 Converts a json string into a UIValidation object
''' '''
return QuillaTest.from_dict(ctx, json.loads(validation_json)) return QuillaTest.from_dict(ctx, json.loads(validation_json))
@classmethod @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 Converts an fp (a .read() supporting file-like object) containing a json
document into a UIValidation object document into a UIValidation object
@ -64,7 +64,7 @@ class QuillaTest(EnumResolver):
return QuillaTest.from_dict(ctx, json.load(fp)) return QuillaTest.from_dict(ctx, json.load(fp))
@classmethod @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 Reads a file at the specified path and attempts to convert it into a
UIValidation object UIValidation object
@ -73,7 +73,7 @@ class QuillaTest(EnumResolver):
return QuillaTest.from_file(ctx, fp) return QuillaTest.from_file(ctx, fp)
@classmethod @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 Converts a dictionary that represents a single UIValidation test case into
the appropriate validation object. the appropriate validation object.

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

@ -46,10 +46,10 @@ def driver():
def pytest_addoption(parser, pluginmanager: PytestPluginManager): def pytest_addoption(parser, pluginmanager: PytestPluginManager):
pluginmanager.set_blocked('quilla') pluginmanager.set_blocked('quilla')
parser.addoption( parser.addoption(
"--quilla-opts", '--quilla-opts',
action="store", action='store',
default="", default='',
help="Options to be passed through to the quilla runtime for the scenario tests" 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): def test_driverholder_returns_expected(self):
holder = DriverHolder() 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.UITestActions,
enums.XPathValidationStates, enums.XPathValidationStates,
enums.URLValidationStates, enums.URLValidationStates,
@ -49,7 +49,7 @@ class UtilTests:
for val in enum_type: for val in enum_type:
assert resolver._name_to_enum(val.value, enum_type) is val assert resolver._name_to_enum(val.value, enum_type) is val
@pytest.mark.parametrize("enum_type", [ @pytest.mark.parametrize('enum_type', [
enums.UITestActions, enums.UITestActions,
enums.XPathValidationStates, enums.XPathValidationStates,
enums.URLValidationStates, enums.URLValidationStates,