コード例 #1
0
def monkeypatch_stitch(
    source_resources, destination_resource, labels=None, tags=None, description=None
):
    file_resource = File(
        name="test_file.txt", type="file", tags=tags, description=description
    )
    file_resource.folder = "/folder1/folder2"
    return file_resource, "123456"
コード例 #2
0
def monkeypatch_upload_files(
    content_type, folder, local_path, description=None, tags=None
):
    return [
        File(
            name="test_file.txt",
            type="file",
            tags=["tags"],
            description="test_description",
        ),
        File(
            name="test_file_2.txt",
            type="file",
            tags=["tags"],
            description="test_description",
        ),
    ]
コード例 #3
0
def file():
    return File(
        raw_model={
            "name": "test_file",
            "type": "file",
            "tags": ["tags"],
            "description": "test_description",
        }
    )
コード例 #4
0
def monkeypatch_create_file(tags=None, description=None, path=None):

    raw_model = {
        "name": "test_file.txt",
        "type": "file",
        "tags": tags,
        "description": description,
    }
    file_resource = File(raw_model=raw_model)
    return file_resource
コード例 #5
0
def monkeypatch_upload_files(media_type,
                             folder,
                             local_path,
                             description=None,
                             tags=None):
    return [
        File(
            raw_model={
                "name": "test_file.txt",
                "type": "file",
                "tags": ["tags"],
                "description": "test_description",
            }),
        File(
            raw_model={
                "name": "test_file_2.txt",
                "type": "file",
                "tags": ["tags"],
                "description": "test_description",
            }),
    ]
コード例 #6
0
def monkeypatch_stitch(
    source_resources, destination_resource, labels=None, tags=None, description=None
):
    file_resource = File(
        raw_model={
            "name": "test_file.txt",
            "type": "file",
            "tags": tags,
            "description": description,
        }
    )
    return file_resource, "123456"
コード例 #7
0
def test_replacing_connection(dataset, helpers, monkeypatch):
    file_name = "/test_file_" + helpers.generate_random_string(16) + ".csv"

    file_1 = dataset.create_file(file_name)

    # Set an invalid API key so refresh() will fail if connection replacement doesn't work
    monkeypatch.setenv("CRUX_API_KEY", "THIS_IS_NOT_A_VALID_KEY")

    # Create new File instance from the raw model of file_1, without a valid connection
    file_2 = File.from_dict(file_1.to_dict())
    # Replace the connection with the one from file_1
    file_2.connection = file_1.connection
    del file_2.raw_model["name"]
    file_2.refresh()

    assert file_2.name == file_1.name
    assert isinstance(file_2, File)

    file_2_dict = file_2.to_dict()
    # Test that to_dict() is making an accurate copy
    assert file_2_dict == file_2.raw_model
    # Test that to_dict() is sctually making a copy
    assert id(file_2_dict) != id(file_2.raw_model)
    assert isinstance(file_2_dict, dict)
コード例 #8
0
def monkeypatch_create_file(tags=None, description=None, path=None):
    file_resource = File(
        name="test_file.txt", type="file", tags=tags, description=description
    )
    file_resource.folder = "/folder1/folder2"
    return file_resource
コード例 #9
0
ファイル: test_file.py プロジェクト: uganti/crux-python
def file():
    return File(name="test_file",
                type="file",
                tags=["tags"],
                description="test_description")