Skip to content

test_layers

test_bare_string_inputs_outputs

test_bare_string_inputs_outputs()

A bare string as input/output should be wrapped, not iterated.

Source code in ezdag/tests/test_layers.py
106
107
108
109
110
111
112
def test_bare_string_inputs_outputs():
    """A bare string as input/output should be wrapped, not iterated."""
    node = Node(inputs="data.txt", outputs="result.txt")
    assert len(node.inputs) == 1
    assert node.inputs[0].name == "data.txt"
    assert len(node.outputs) == 1
    assert node.outputs[0].name == "result.txt"

test_layer_new

test_layer_new(mock_which)

Layer.new() copies config but not nodes.

Source code in ezdag/tests/test_layers.py
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@mock.patch("shutil.which", side_effect=lambda x: f"/path/to/{x}")
def test_layer_new(mock_which):
    """Layer.new() copies config but not nodes."""
    layer = Layer(
        "my_exec",
        name="custom",
        universe="docker",
        log_dir="my_logs",
        retries=5,
        transfer_files=False,
        submit_description={"request_cpus": 4},
    )
    layer += Node(arguments=Argument("x", 1))

    clone = layer.new()

    assert clone.executable == layer.executable
    assert clone.name == layer.name
    assert clone.universe == layer.universe
    assert clone.log_dir == layer.log_dir
    assert clone.retries == layer.retries
    assert clone.transfer_files == layer.transfer_files
    assert clone.submit_description == layer.submit_description
    assert clone.nodes == []

test_static_literal_inputs_outputs

test_static_literal_inputs_outputs(mock_which)

Bare strings as inputs/outputs become static Literals.

Source code in ezdag/tests/test_layers.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@mock.patch("shutil.which", side_effect=lambda x: f"/path/to/{x}")
def test_static_literal_inputs_outputs(mock_which):
    """Bare strings as inputs/outputs become static Literals."""
    layer = Layer("my_exec")
    layer += Node(
        arguments=Argument("idx", 0),
        inputs=["data.txt"],
        outputs=["/path/to/result.txt"],
    )
    config = layer.config()
    submit = config["submit_description"]

    # static inputs appear directly in arguments (not as condor variables)
    assert "data.txt" in submit["arguments"]
    # static outputs get basified when transfer is on
    assert "result.txt" in submit["arguments"]

    # file transfer lists include the static files directly
    assert "data.txt" in submit["transfer_input_files"]
    assert "result.txt" in submit["transfer_output_files"]

    # absolute path produces a remap
    assert "result.txt=/path/to/result.txt" in submit["transfer_output_remaps"]