mik-laj commented on a change in pull request #9874:
URL: https://github.com/apache/airflow/pull/9874#discussion_r456829305
##########
File path: tests/providers/apache/cassandra/sensors/test_table.py
##########
@@ -21,14 +21,36 @@
from airflow.providers.apache.cassandra.sensors.table import
CassandraTableSensor
+TEST_CASSANDRA_CONN_ID = 'cassandra_default'
+TEST_CASSANDRA_TABLE = 't'
+TEST_CASSANDRA_TABLE_WITH_KEYSPACE = 'keyspacename.tablename'
+
class TestCassandraTableSensor(unittest.TestCase):
@patch("airflow.providers.apache.cassandra.sensors.table.CassandraHook")
def test_poke(self, mock_hook):
sensor = CassandraTableSensor(
task_id='test_task',
- cassandra_conn_id='cassandra_default',
- table='t',
+ cassandra_conn_id=TEST_CASSANDRA_CONN_ID,
+ table=TEST_CASSANDRA_TABLE,
+ )
+ exists = sensor.poke(dict())
+
+ self.assertTrue(exists)
+
+
mock_hook.return_value.table_exists.assert_called_once_with(TEST_CASSANDRA_TABLE)
+ mock_hook.assert_called_once_with(TEST_CASSANDRA_CONN_ID)
+
+ @patch("airflow.providers.apache.cassandra.sensors.table.CassandraHook")
+ def test_poke_should_succeed_for_table_with_mentioned_keyspace(self,
mock_hook):
+ sensor = CassandraTableSensor(
+ task_id='test_task',
+ cassandra_conn_id=TEST_CASSANDRA_CONN_ID,
+ table=TEST_CASSANDRA_TABLE_WITH_KEYSPACE,
)
- sensor.poke(None)
- mock_hook.return_value.table_exists.assert_called_once_with('t')
+ exists = sensor.poke(dict())
+
+ self.assertTrue(exists)
Review comment:
Can you add a test that will check False?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]