Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: test: convert to dir helpers 1 #2898

Merged
merged 1 commit into from
Dec 6, 2019
Merged

Conversation

pared
Copy link
Contributor

@pared pared commented Dec 5, 2019

test_add_file_in_dir
test_readding_dir_should_not_unprotect_all
test_should_not_checkout_when_adding_cached_copy

  • ❗ Have you followed the guidelines in the Contributing to DVC list?

  • πŸ“– Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.

  • ❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

related to #2896

Started doing whole test_add, but iterations will probably be faster in batches, also reviewing 3 changed tests is easier than 20.

@pared pared requested a review from a user December 5, 2019 19:45
@@ -168,17 +168,19 @@ def test(self):
self.assertTrue(stages[0] is not None)


def test_add_file_in_dir(repo_dir, dvc_repo):
stage, = dvc_repo.add(repo_dir.DATA_SUB)
def test_add_file_in_dir(dvc, tmp_dir):
Copy link
Contributor

@Suor Suor Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order doesn't matter to python, but it matters to reader. Let's list fixtures in the same order everywhere: tmp_dir, scm (if used), dvc. This is chronological: temp dir is created, then git init, then dvc init.

new_file = os.path.join(repo_dir.DATA_DIR, "new_file")
def test_readding_dir_should_not_unprotect_all(dvc, tmp_dir, mocker):
tmp_dir.gen({"dir": {"data": "data"}})
dvc.cache.local.cache_types = ["symlink"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an empty line after tmp_dir.gen(), up to you.


repo_dir.create(new_file, "new_content")
dvc.add("dir")
tmp_dir.gen({"dir": {"new_file": "new_file_content"}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other option:

tmp_dir.get("dir/new_file", "new_file_contents")

Less punctuation.

shutil.copy(repo_dir.BAR, repo_dir.FOO)
tmp_dir.gen({"foo": "foo", "bar": "bar"})
dvc.add("foo")
dvc.add("bar")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace 3 lines with:

Suggested change
dvc.add("bar")
tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})

test_add_file_in_dir
test_readding_dir_should_not_unprotect_all
test_should_not_checkout_when_adding_cached_copy
@efiop efiop merged commit 9b6644a into iterative:master Dec 6, 2019
@efiop efiop added the testing Related to the tests and the testing infrastructure label Dec 6, 2019
@pared pared deleted the 2896_add_1 branch December 17, 2019 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Related to the tests and the testing infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants