def _assert_get_lb_policy(self, policy_name, policy_args, expected_policy_type, expected_child_policy_type=None, should_throw=False): thrown = False try: policy = CassandraHook.get_lb_policy(policy_name, policy_args) self.assertTrue(isinstance(policy, expected_policy_type)) if expected_child_policy_type: self.assertTrue(isinstance(policy._child_policy, expected_child_policy_type)) except Exception: thrown = True self.assertEqual(should_throw, thrown)
# 'queue': 'bash_queue', # 'pool': 'backfill', # 'priority_weight': 10, # 'end_date': datetime(2016, 1, 1), # 'wait_for_downstream': False, # 'dag': dag, # 'sla': timedelta(hours=2), # 'execution_timeout': timedelta(seconds=300), # 'on_failure_callback': some_function, # 'on_success_callback': some_other_function, # 'on_retry_callback': another_function, # 'sla_miss_callback': yet_another_function, # 'trigger_rule': 'all_success' } hook = CassandraHook('cassandra_default') pp = pprint.PrettyPrinter(indent=4) def check_table_exists(keyspace_name, table_name): print("Checking for existence of "+keyspace_name+"."+table_name) hook.keyspace = keyspace_name return hook.table_exists(table_name) def execute_query(query): pp.pprint( hook.get_conn().execute(query).current_rows ) select_all_query = "SELECT * FROM test.users;" with DAG( 'cass_hooks_tutorial', default_args=default_args,