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

Improve test coverage #32

Merged
merged 5 commits into from Jul 24, 2019

Conversation

wisp3rwind
Copy link
Collaborator

The tests that I added are fairly simple though, but hopefully still better than nothing. Now waiting for Travis...

@wisp3rwind
Copy link
Collaborator Author

Force-pushed flake8 fixes.

Copy link
Owner

@geigerzaehler geigerzaehler left a comment

Choose a reason for hiding this comment

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

This is a great addition!

One thing I would like to ask is for you to add documentation to all the new and changed methods. I haven’t been exemplary on that front either. To make up for it I added docs for this PR. Feel free to change them in any way.

test/helper.py Outdated
@@ -258,6 +278,11 @@ def lib_path(self, path):
return os.path.join(self.libdir,
path.replace(b'/', bytestring_path(os.sep)))

def item_fixture_path(self, fmt, bytestring=True):
Copy link
Owner

Choose a reason for hiding this comment

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

The bytestring argument is unused. Can we remove it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I thought that I'll need that to construct config values with that path in them, but in the end didn't. Thanks for spotting this!

test/cli_test.py Outdated
self.lib_path(b'Michael Jackson/Thriller/track 1.mp3'),
)
by_orig_year_path = self.lib_path(b'by-year/1982/Thriller/track 1.mp3')
self.assertIsNotSymlink(by_year_path)
Copy link
Owner

Choose a reason for hiding this comment

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

I think it would make more sense to check that the path does not exist at all. It would be easier to understand than assertIsNotSymlink and we would catch issues when the file still exists but is not a symlink.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm also not really happy with that name. I added an additional assertion, because assertIsFile uses os.path.isfile, which IIRC follows symlinks and stats the target, i.e. if for some reason a symlink ends up being broken, it will not be detected. So if read the documentation correctly, os.path.lexists should precisely check that the path does not exist at all. Which os/os.path method do you think should be used by this test?

Copy link
Owner

Choose a reason for hiding this comment

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

How about renaming assertIsNotSymlink to assertIsNotFile and use not os.path.isfile() and not os.path.islink()?

test/helper.py Show resolved Hide resolved
@@ -69,7 +69,11 @@ def test_external(self):
self.assertFalse(os.path.isfile(external_from_ogg))
self.assertFileTag(external_beet, b'ISAAC')

def test_symlink_view(self):

class SymlinkViewTest(TestHelper):
Copy link
Owner

Choose a reason for hiding this comment

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

Docs:

"""Test alternatives with the ``link`` format producing symbolic links.
"""

test/cli_test.py Show resolved Hide resolved
…ing Worker/ThreadPoolExecutor

Fakes the conversion process by copying a fixture of another format. The
conversion worker will rewrite the tags anyway.
@wisp3rwind
Copy link
Collaborator Author

Going to force-push your additions to the docs + a few more.

test/cli_test.py Outdated
class ExternalConvertWorkerTest(TestHelper):
"""Test alternatives with non-empty ``format `` option, i.e. transcoding
some of the files. In contrast to the previous test, these test do not
work the parallelizing Worker.
Copy link
Owner

Choose a reason for hiding this comment

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

I think you mistyped. These tests do use the production worker

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed I did...

Copy link
Owner

@geigerzaehler geigerzaehler left a comment

Choose a reason for hiding this comment

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

👏 🎉

@wisp3rwind wisp3rwind merged commit 1053b01 into geigerzaehler:master Jul 24, 2019
@wisp3rwind wisp3rwind deleted the pr-improve-coverage branch July 24, 2019 09:15
daviddavo pushed a commit to daviddavo/beets-alternatives that referenced this pull request Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants