Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Dec 14, 2019

No description provided.

def test_return_true_on_dvc_internal_file(self):
path = os.path.join("path", "to", ".dvc", "file")
self.assertTrue(path)
def test_destroy(tmp_dir, dvc):
Copy link
Author

Choose a reason for hiding this comment

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

moved .destroy, .collect, .status to the unit test module. the reason behind it is that we are testing the behavior of a single unit, in this case, a single method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still look like functional tests to me. We recreate the whole scenario and call a method, which is a mirror of cli command.

Copy link
Author

Choose a reason for hiding this comment

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

got it, will bring them back

Copy link
Author

Choose a reason for hiding this comment

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

@Suor , for future references, how do you make the distinction between functional and unit tests?

@ghost ghost requested review from Suor, efiop and pared and removed request for Suor December 14, 2019 00:13
@efiop
Copy link
Contributor

efiop commented Dec 14, 2019

@MrOutis Please check tests, they are failing.

@ghost
Copy link
Author

ghost commented Dec 14, 2019

@efiop , thanks for the notice

@efiop
Copy link
Contributor

efiop commented Dec 16, 2019

@MrOutis tests are still failing

def test_return_true_on_dvc_internal_file(self):
path = os.path.join("path", "to", ".dvc", "file")
self.assertTrue(path)
def test_destroy(tmp_dir, dvc):
Copy link
Contributor

Choose a reason for hiding this comment

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

Still look like functional tests to me. We recreate the whole scenario and call a method, which is a mirror of cli command.

@ghost ghost requested a review from Suor December 16, 2019 18:49

def test_destroy(tmp_dir, dvc):
dvc.config.set("cache", "type", "symlink")

Copy link
Contributor

Choose a reason for hiding this comment

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

dvc.cache = Cache(dvc)
setting cache type does not reload it, and last check is always true


self.create(DvcIgnore.DVCIGNORE_FILE, self.DATA_DIR)
assert stages() == {
os.path.join("file.dvc"),
Copy link
Contributor

Choose a reason for hiding this comment

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

is there need for os.path.join here?

Copy link
Author

@ghost ghost Dec 17, 2019

Choose a reason for hiding this comment

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

no need, but just to keep it consistent 😅

Comment on lines 41 to 43
run_copy("bar", "buzz")
assert collect_outs("buzz.dvc", with_deps=True) == {"foo", "bar", "buzz"}
assert collect_outs("buzz.dvc", with_deps=False) == {"buzz"}
Copy link
Contributor

Choose a reason for hiding this comment

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

The "buzz" was added in a branch originally. And it was a collect with a branch assigned.

Copy link
Author

Choose a reason for hiding this comment

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

I think it doesn't make sense to do the branching, but I'll do it just to not be a blocker for this PR

self.assertEqual(0, ret)
def test_stages(tmp_dir, dvc):
def stages():
return set(stage.relpath for stage in Repo(str(tmp_dir)).stages)
Copy link
Contributor

Choose a reason for hiding this comment

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

str -> fspath

self.assertTrue(path)
def test_is_dvc_internal(tmp_dir, dvc):
assert dvc.is_dvc_internal(fspath(tmp_dir / ".dvc" / "file"))
assert not dvc.is_dvc_internal("file")
Copy link
Contributor

Choose a reason for hiding this comment

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

The test was quite different before:

  • testing relative paths always
  • testing .dvc not in the repo root (still considered internal, don't know why)
  • testing tricky dirname "to-non-.dvc" (not sure if that is important)

Copy link
Author

Choose a reason for hiding this comment

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

@pared , where those intended? I'll leave them as it was before for now

@efiop efiop assigned ghost Dec 17, 2019
@efiop efiop added refactoring Factoring and re-factoring testing Related to the tests and the testing infrastructure labels Dec 17, 2019
@ghost ghost requested review from Suor, efiop and pared December 17, 2019 18:14
@efiop efiop merged commit 477488e into iterative:master Dec 17, 2019
@ghost ghost deleted the tests-repo branch December 17, 2019 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Factoring and re-factoring testing Related to the tests and the testing infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants