def test_context(self): client = get_host_client() test_context = {'foo': 'bar'} tmp_dir = 'META_DIR' with mock.patch('airflow_docker_helper.serialize_context', return_value=test_context): client.write_context(test_context, tmp_dir) open_file = client._mock_context_file() assert len(open_file.write.mock_calls) == 1 _, args, kwargs = open_file.write.mock_calls[0] assert args[0] == b'{"foo": "bar"}'
def test_write_value(self): client = get_host_client( xcom_push= b'{"key": "foo", "value": [1]}\n{"key": "foo2", "value": [2]}\n') tmp_dir = "META_DIR" data = client.get_xcom_push_data(tmp_dir) assert data == [{ "key": "foo", "value": [1] }, { "key": "foo2", "value": [2] }]
def test_one_task_id(self): client = get_host_client(task_ids=['foo']) tmp_dir = 'META_DIR' task_ids = client.branch_task_ids(tmp_dir) assert task_ids == ['foo']
def test_no_short_circuit(self): client = get_host_client() tmp_dir = 'META_DIR' short_circuit_outcome = client.short_circuit_outcome(tmp_dir) assert short_circuit_outcome is True
def test_no_outcome(self): client = get_host_client() tmp_dir = 'META_DIR' sensor_outcome = client.sensor_outcome(tmp_dir) assert sensor_outcome is False
def test_true_outcome(self): client = get_host_client(sensor=True) tmp_dir = 'META_DIR' sensor_outcome = client.sensor_outcome(tmp_dir) assert sensor_outcome is True
def test_no_task_ids(self): client = get_host_client() tmp_dir = 'META_DIR' task_ids = client.branch_task_ids(tmp_dir) assert task_ids == []
def test_no_outcome(self): client = get_host_client() tmp_dir = "META_DIR" data = client.get_xcom_push_data(tmp_dir) assert data == []
def test_one_task_id(self): client = get_host_client(task_ids=["foo"]) tmp_dir = "META_DIR" task_ids = client.branch_task_ids(tmp_dir) assert task_ids == ["foo"]
def test_short_circuit(self): client = get_host_client(short_circuit=False) tmp_dir = "META_DIR" short_circuit_outcome = client.short_circuit_outcome(tmp_dir) assert short_circuit_outcome is False
def test_false_outcome(self): client = get_host_client(sensor=False) tmp_dir = "META_DIR" sensor_outcome = client.sensor_outcome(tmp_dir) assert sensor_outcome is False