Beispiel #1
0
    def test_protocol_usage(self, filepath, instance_type):
        data_set = NetworkXDataSet(filepath=filepath)
        assert isinstance(data_set._fs, instance_type)

        path = filepath.split(PROTOCOL_DELIMITER, 1)[-1]

        assert str(data_set._filepath) == path
        assert isinstance(data_set._filepath, PurePosixPath)
Beispiel #2
0
    def test_version_str_repr(self, load_version, save_version):
        """Test that version is in string representation of the class instance
        when applicable."""
        filepath = "test.json"
        ds = NetworkXDataSet(filepath=filepath)
        ds_versioned = NetworkXDataSet(filepath=filepath,
                                       version=Version(load_version,
                                                       save_version))
        assert filepath in str(ds)
        assert "version" not in str(ds)

        assert filepath in str(ds_versioned)
        ver_str = f"version=Version(load={load_version}, save='{save_version}')"
        assert ver_str in str(ds_versioned)
        assert "NetworkXDataSet" in str(ds_versioned)
        assert "NetworkXDataSet" in str(ds)
        assert "protocol" in str(ds_versioned)
        assert "protocol" in str(ds)
    def test_protocol_usage(self, filepath, instance_type):
        data_set = NetworkXDataSet(filepath=filepath)
        assert isinstance(data_set._fs, instance_type)

        # _strip_protocol() doesn't strip http(s) protocol
        if data_set._protocol == "https":
            path = filepath.split("://")[-1]
        else:
            path = data_set._fs._strip_protocol(filepath)

        assert str(data_set._filepath) == path
        assert isinstance(data_set._filepath, PurePosixPath)
Beispiel #4
0
def networkx_data_set_args(filepath_json):
    return NetworkXDataSet(filepath=filepath_json,
                           load_args={"attrs": ATTRS},
                           save_args={"attrs": ATTRS})
Beispiel #5
0
def versioned_networkx_data_set(filepath_json, load_version, save_version):
    return NetworkXDataSet(filepath=filepath_json,
                           version=Version(load_version, save_version))
Beispiel #6
0
def networkx_data_set(filepath_json, fs_args):
    return NetworkXDataSet(filepath=filepath_json, fs_args=fs_args)
Beispiel #7
0
 def test_catalog_release(self, mocker):
     fs_mock = mocker.patch("fsspec.filesystem").return_value
     filepath = "test.json"
     data_set = NetworkXDataSet(filepath=filepath)
     data_set.release()
     fs_mock.invalidate_cache.assert_called_once_with(filepath)
def networkx_data_set(filepath_json):
    return NetworkXDataSet(filepath=filepath_json)