sampsyo/beets — pull request #510 by geigerzaehler (2014-01-28 13:11:36+00:00)
Title: Import Test Refactor

These commits streamline `test_importer.py` and increase coverage from 43% to 49%. I try to implement importing albums from a flat directory, so this seemed the first natural step to get aquainted with the implementation.

It is **not yet complete**. I will try to migrate all tests.

### Helper Class
To **setup tests** for `ImportSession` we need to create a library, files to import, and an instance of the session. I abstraced those into the `ImportHelper` class which is mixed into the test cases. We also need to **stub out** two components

1. Retrieval from information through the `mb.match_album` and `mb.match_track` functions
2. Interaction of the session with the user through the `choose_*` methods.

These are provided by`ImportHelper`, too. Finally we need to **control the tags** of the files to import. This is achieved through the `import_media` property, a list that contains `MediaFile` instances for all files to be imported.

### Changed Test Cases
I rewrote the `NonAutotaggedImportTest` case using the `ImportHelper`. I also added two new test cases for basic import and compilations and reimplemented some tests from `ImportApplyTest` and `AsIsApplyTest` in these classes. Finally I removed the old duplicated tests.