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

ftintitle plugin now allows a custom format to be defined (Correct Branch) #1377

Merged
merged 5 commits into from Mar 29, 2015

Conversation

ab623
Copy link
Contributor

@ab623 ab623 commented Mar 24, 2015

(Apologies for the duplicate request, but I referenced the incorrect branch. Thanks.)

I have updated the ftintitle plugin to allow a custom format to be defined. The default format is that which was previously hardcoded.

This pull request allows formats like the list below to be defined:

  • feat. ...
  • (Feat. ...)
  • ft. ...
  • featuring ...

This is my first commit to an open source project, so I'm still working my way around the beets project. Any feedback would be great.

Thanks

@brunal
Copy link
Collaborator

brunal commented Mar 25, 2015

Hi,
Could you add a test in test/test_ftintitle.py? And set feat. as the default value in the default config (beets/default_config.yaml)?

Finally shouldn't we allow multiple formats: a list of formats instead of a single format?

@ab623
Copy link
Contributor Author

ab623 commented Mar 25, 2015

I'll add the tests. How would you go about testing a item.store()

I didn't add the default value because not all plugins register their defaults in the default config (ftintitle wasn't there previously, do I didn't add to it), I will add it however if required.

In regards to into the multiple formats, why would you want to define a list. I would want my music to follow the same format of how I define my feat. I'm unsure as to the use case in which this would be relevant.

@brunal
Copy link
Collaborator

brunal commented Mar 25, 2015

I'll add the tests. How would you go about testing a item.store()

Why would you want to test it? What's important is testing the ft_in_title() method IMO. And if you want to do functional testing with TestHelper.run_command() (which is a nice additional test) you don't need to mock Item.store() since it happens in a temporary beets environment (see TestHelper.setup_beets() and its usages).
In general (but not in this case) you would mock the method: item.store = mock.Mock. That way you can even assert how many times it's been called and with what arguments (see usages of assert_has_calls and assert_called_once).

I didn't add the default value because not all plugins register their defaults in the default config [...]

Good point.

In regards to into the multiple formats, why would you want to define a list.
Never mind. I don't use that plugin and I was mistaken on its functionality.

@ab623
Copy link
Contributor Author

ab623 commented Mar 27, 2015

Hi @brunal

I have simplified the implementation, as the previous code was passing parameters into functions that it didn't need to.

Thank you also for pointing me in the direction for the functional tests. I learnt a great deal about them and gave it my best shot. The ftintitle plugin has no functional tests at all, so I created a new class for them, and have added a few, not only surrounding my changes but also for the "drop" feat option too.

I hope this is okay.

@ab623
Copy link
Contributor Author

ab623 commented Mar 27, 2015

Looks like I have some issues to sort out in the build. I'll get on it.

@ab623
Copy link
Contributor Author

ab623 commented Mar 27, 2015

Build looks good. Comments are welcome :)

@@ -24,6 +24,9 @@ file. The available options are:
- **drop**: Remove featured artists entirely instead of adding them to the
title field.
Default: ``no``.
- **format**: Defines the format for the feat part of the new title field.
In this format the ``{0}`` is used to define where the featured artists are placed
Copy link
Member

Choose a reason for hiding this comment

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

Missing a period at the end of the sentence.

@sampsyo
Copy link
Member

sampsyo commented Mar 28, 2015

LGTM! I made a few very tiny style suggestions, after which I think this will be all ready.

And the tests are awesome!

@ab623
Copy link
Contributor Author

ab623 commented Mar 28, 2015

Hi @sampsyo
The changes you requested have been added.

:)

@sampsyo sampsyo merged commit 9a38b07 into beetbox:master Mar 29, 2015
sampsyo added a commit that referenced this pull request Mar 29, 2015
ftintitle plugin now allows a custom format to be defined (Correct Branch)
sampsyo added a commit that referenced this pull request Mar 29, 2015
@sampsyo
Copy link
Member

sampsyo commented Mar 29, 2015

Awesome! ✨ Thanks for implementing this. All merged.

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

3 participants