Skip to content

Commit

Permalink
Blacken
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmreed committed Sep 27, 2023
1 parent ed1667b commit fb15376
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
22 changes: 8 additions & 14 deletions cumulusci/tasks/apex/testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ def _init_options(self, kwargs):
self.options.get("required_per_class_code_coverage_percent", 0)
)
# Raises a TaskOptionsError when the user provides both test_suite_names and test_name_match.
if (
self.options["test_suite_names"]
) and (
if (self.options["test_suite_names"]) and (
self.options["test_name_match"] is not None
and self.options["test_name_match"] != "%_TEST%"
):
Expand Down Expand Up @@ -301,18 +299,15 @@ def _get_test_class_query(self):

def _get_test_classes(self):
# If test_suite_names is provided, execute only tests that are a part of the list of test suites provided.
if (
self.options["test_suite_names"]
):
if self.options["test_suite_names"]:
test_classes_from_test_suite_names = (
self._get_test_classes_from_test_suite_names()
)
return test_classes_from_test_suite_names

# test_suite_names is not provided. Fetch all the test classes from the org.
else:
return self._get_all_test_classes()


def _get_all_test_classes(self):
# Fetches all the test classes from the org.
Expand All @@ -321,13 +316,11 @@ def _get_all_test_classes(self):
result = self.tooling.query_all(query)
self.logger.info("Found {} test classes".format(result["totalSize"]))
return result

def _get_comma_separated_string_of_items(self, itemlist):
# Accepts a list of strings. A formatted string is returned.
# Example: Input: ['TestSuite1', 'TestSuite2'] Output: ''TestSuite1','TestSuite2''
return ",".join(
[f"'{item}'" for item in itemlist]
)
return ",".join([f"'{item}'" for item in itemlist])

def _get_test_suite_ids_from_test_suite_names_query(self, test_suite_names_arg):
# Returns a query string which when executed fetches the test suite ids of the list of test suite names.
Expand Down Expand Up @@ -361,7 +354,9 @@ def _get_test_classes_from_test_suite_ids_query(self, testSuiteIds):
def _get_test_classes_from_test_suite_names(self):
# Returns a list of Apex test classes that belong to the test suite(s) specified. Test classes specified in test_name_exclude are excluded.
test_suite_names_arg = self.options["test_suite_names"]
query1 = self._get_test_suite_ids_from_test_suite_names_query(test_suite_names_arg)
query1 = self._get_test_suite_ids_from_test_suite_names_query(
test_suite_names_arg
)
self.logger.info("Fetching test suite metadata...")
result = self.tooling.query_all(query1)
testSuiteIds = []
Expand Down Expand Up @@ -600,7 +595,6 @@ def _init_task(self):
)

def _run_task(self):

result = self._get_test_classes()
if result["totalSize"] == 0:
return
Expand Down
16 changes: 9 additions & 7 deletions cumulusci/tasks/apex/tests/test_apex_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _get_mock_test_query_results(self, methodnames, outcomes, messages):

return_value = {"done": True, "records": []}

for (method_name, outcome, message) in zip(methodnames, outcomes, messages):
for method_name, outcome, message in zip(methodnames, outcomes, messages):
this_result = deepcopy(record_base)
this_result["Message"] = message
this_result["Outcome"] = outcome
Expand Down Expand Up @@ -737,8 +737,10 @@ def test_get_test_suite_ids_from_test_suite_names_query__multiple_test_suites(se
}
)
task = RunApexTests(self.project_config, task_config, self.org_config)
test_suite_names_arg = 'TestSuite1,TestSuite2'
query = task._get_test_suite_ids_from_test_suite_names_query(test_suite_names_arg)
test_suite_names_arg = "TestSuite1,TestSuite2"
query = task._get_test_suite_ids_from_test_suite_names_query(
test_suite_names_arg
)

assert (
"SELECT Id, TestSuiteName FROM ApexTestSuite WHERE TestSuiteName IN ('TestSuite1','TestSuite2')"
Expand All @@ -756,9 +758,11 @@ def test_get_test_suite_ids_from_test_suite_names_query__single_test_suite(self)
}
}
)
test_suite_names_arg = 'TestSuite1'
test_suite_names_arg = "TestSuite1"
task = RunApexTests(self.project_config, task_config, self.org_config)
query = task._get_test_suite_ids_from_test_suite_names_query(test_suite_names_arg)
query = task._get_test_suite_ids_from_test_suite_names_query(
test_suite_names_arg
)

assert (
"SELECT Id, TestSuiteName FROM ApexTestSuite WHERE TestSuiteName IN ('TestSuite1')"
Expand Down Expand Up @@ -1357,7 +1361,6 @@ def mock_poll_action():

@responses.activate
def test_job_not_found(self):

task, url = self._get_url_and_task()
response = self._get_query_resp()
response["records"] = []
Expand Down Expand Up @@ -1392,7 +1395,6 @@ def test_run_tests__integration_test(self, create_task, caplog, vcr):
self._test_run_tests__integration_test(create_task, caplog)

def _test_run_tests__integration_test(self, create_task, caplog):

caplog.set_level(logging.INFO)
with pytest.raises(exc.ApexTestException) as e:
task = create_task(
Expand Down

0 comments on commit fb15376

Please sign in to comment.