Skip to content

Commit

Permalink
[AIRFLOW-857] Use library assert statements instead of conditionals
Browse files Browse the repository at this point in the history
Testing Done:
- Travis

Closes apache#2062 from saguziel/aguziel-fix-asserts
  • Loading branch information
saguziel authored and aoen committed Feb 10, 2017
1 parent b56e642 commit 3ceb3ab
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 268 deletions.
2 changes: 1 addition & 1 deletion tests/contrib/hooks/test_jira_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):
def test_jira_client_connection(self, jira_mock):
jira_hook = JiraHook()

assert jira_mock.called
self.assertTrue(jira_mock.called)
self.assertIsInstance(jira_hook.client, Mock)
self.assertEqual(jira_hook.client.name, jira_mock.return_value.name)

Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/operators/dataflow_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_exec(self, gcs_hook, dataflow_mock):
start_python_hook = dataflow_mock.return_value.start_python_dataflow
gcs_download_hook = gcs_hook.return_value.download
self.dataflow.execute(None)
assert dataflow_mock.called
self.assertTrue(dataflow_mock.called)
expected_options = {
'project': 'test',
'staging_location': 'gs://test/staging',
Expand Down
8 changes: 4 additions & 4 deletions tests/contrib/operators/jira_operator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def test_issue_search(self, jira_mock):
jira_ticket_search_operator.run(start_date=DEFAULT_DATE,
end_date=DEFAULT_DATE, ignore_ti_state=True)

assert jira_mock.called
assert jira_mock.return_value.search_issues.called
self.assertTrue(jira_mock.called)
self.assertTrue(jira_mock.return_value.search_issues.called)

@patch("airflow.contrib.hooks.jira_hook.JIRA",
autospec=True, return_value=jira_client_mock)
Expand All @@ -93,8 +93,8 @@ def test_update_issue(self, jira_mock):
add_comment_operator.run(start_date=DEFAULT_DATE,
end_date=DEFAULT_DATE, ignore_ti_state=True)

assert jira_mock.called
assert jira_mock.return_value.add_comment.called
self.assertTrue(jira_mock.called)
self.assertTrue(jira_mock.return_value.add_comment.called)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/sensors/hdfs_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,4 @@ def test_should_match_regex_but_copyingext(self):
# When
# Then
with self.assertRaises(AirflowSensorTimeout):
task.execute(None)
task.execute(None)
4 changes: 2 additions & 2 deletions tests/contrib/sensors/jira_sensor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def test_issue_label_set(self, jira_mock):
ticket_label_sensor.run(start_date=DEFAULT_DATE,
end_date=DEFAULT_DATE, ignore_ti_state=True)

assert jira_mock.called
assert jira_mock.return_value.issue.called
self.assertTrue(jira_mock.called)
self.assertTrue(jira_mock.return_value.issue.called)

@staticmethod
def field_checker_func(context, issue):
Expand Down
Loading

0 comments on commit 3ceb3ab

Please sign in to comment.