Пример #1
0
def test_process(files):
    files = files["resources"]
    file_1 = files["file_1"]
    file_2 = files["file_2"]

    tfm = Transformer([], SingleJsonRetriever())
    tfm.files = [file_1, file_2]

    expected_result = [{
        "data": [
            {
                "value": 101,
                "xaxis": 1,
                "file": file_1
            },
            {
                "value": 102,
                "xaxis": 1,
                "file": file_1
            },
            {
                "value": 103,
                "xaxis": 1,
                "file": file_1
            },
            {
                "value": 201,
                "xaxis": 2,
                "file": file_2
            },
            {
                "value": 202,
                "xaxis": 2,
                "file": file_2
            },
            {
                "value": 203,
                "xaxis": 2,
                "file": file_2
            },
        ],
        "subtest":
        "browserScripts.timings.firstPaint",
        "name":
        "group_1",
    }]

    actual_result = tfm.process("group_1")

    assert actual_result == expected_result
Пример #2
0
def test_jsonschema_valitate_failure(files):
    class BadTransformer:
        def transform(self, data):
            return {"bad data": "bad data"}

        def merge(self, sde):
            return {"bad data": "bad data"}

    files = files["resources"]
    file_1 = files["file_1"]
    file_2 = files["file_2"]

    tfm = Transformer([], BadTransformer(), logger=metadata, prefix=prefix)
    tfm.files = [file_1, file_2]
    with pytest.raises(ValidationError):
        tfm.process("name")
Пример #3
0
def test_files_setter_failure():
    tfm = Transformer(logger=metadata, prefix=prefix)
    tfm.files = "fail"
    assert not tfm.files
Пример #4
0
def test_files_setter(files):
    files = files["resources"]
    files = list(files.values())
    tfm = Transformer(logger=metadata, prefix=prefix)
    tfm.files = files
    assert files == tfm.files
Пример #5
0
def test_files_setter_failure():
    tfm = Transformer()
    tfm.files = "fail"
    assert not tfm.files
Пример #6
0
def test_files_setter(files):
    files, _, _ = files
    files = list(files.values())
    tfm = Transformer()
    tfm.files = files
    assert files == tfm.files