[#4136] fixed recalculating relative paths in config#4802
Conversation
5255622 to
7a0eb1d
Compare
efiop
left a comment
There was a problem hiding this comment.
Thanks for the PR! Looks great!
Could we slim down the tests to just test that the paths are adjusted properly when loading a config with these fields? Current tests do the job, but they are quite heavy for such a simple function. Also, I see a lot of code duplication in the tests, would it be possible to reasonably us e pytest parametrize helper?
There was a problem hiding this comment.
Linter CI job is complaining about this one
| assert main(["remote", "add", "-d", remote_name, remote_url,]) == 0 | |
| assert main(["remote", "add", "-d", remote_name, remote_url]) == 0 |
|
I'm not sure. Current tests involve setting paths and loading them in a config. Proposed test would do only the second part. |
There was a problem hiding this comment.
Seems like this is testing how it is written to the config file, but not really how it is loaded. Or am I missing something?
|
@godfryd The setting part is pretty safe. You are currently using CLI and realoding the whole repo instance in order to test it, but you could really just do something like: which should be easily parametrizable (or could even shove everything into one test without parametrizations), simple and lightweight. What do you think? |
ac17e14 to
2b4223c
Compare
efiop
left a comment
There was a problem hiding this comment.
Looks great! Please take a look at the windows tests, looks like there is a bug
2020-11-07T09:49:32.2041318Z def test_load_relative_paths(dvc, field, remote_url):
2020-11-07T09:49:32.2041690Z # set field to test
2020-11-07T09:49:32.2042032Z with dvc.config.edit() as conf:
2020-11-07T09:49:32.2042463Z conf["remote"]["test"] = {"url": remote_url, field: "file.txt"}
2020-11-07T09:49:32.2042793Z
2020-11-07T09:49:32.2043269Z # check if written paths are correct
2020-11-07T09:49:32.2043710Z dvc_dir = dvc.config.dvc_dir
2020-11-07T09:49:32.2044307Z > assert dvc.config["remote"]["test"][field] == os.path.join(
2020-11-07T09:49:32.2044735Z dvc_dir, "..", "file.txt"
2020-11-07T09:49:32.2045003Z )
2020-11-07T09:49:32.2045425Z E AssertionError: assert 'C:\\Users\\r...\\../file.txt' == 'C:\\Users\\r...\..\\file.txt'
2020-11-07T09:49:32.2046433Z E - C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\popen-gw3\test_load_relative_paths_cert_0\.dvc\..\file.txt
2020-11-07T09:49:32.2047086Z E ? ^
2020-11-07T09:49:32.2047786Z E + C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\popen-gw3\test_load_relative_paths_cert_0\.dvc\../file.txt
2020-11-07T09:49:32.2048624Z E ?
a8dc8dd to
9396c3c
Compare
Other paths beside gdrive_user_credentials_file and cache.dir should be recalculated.
Added the following ones:
Will fix #4136.