mirror of
https://github.com/beetbox/beets.git
synced 2026-02-26 09:11:32 +01:00
mbsubmit: add basic tests
* Add basic unit tests for the mbsubmit plugin, covering the output of the "Print tracks" option on albums and singletons.
This commit is contained in:
parent
8746869f7c
commit
966746fd55
1 changed files with 72 additions and 0 deletions
72
test/test_mbsubmit.py
Normal file
72
test/test_mbsubmit.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of beets.
|
||||
# Copyright 2015, Adrian Sampson and Diego Moreda.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
from __future__ import (division, absolute_import, print_function,
|
||||
unicode_literals)
|
||||
|
||||
from test._common import unittest
|
||||
from test.helper import capture_stdout, control_stdin, TestHelper
|
||||
from test.test_importer import ImportHelper, AutotagStub
|
||||
from test.test_ui_importer import TerminalImportSessionSetup
|
||||
|
||||
|
||||
class MBSubmitPluginTest(TerminalImportSessionSetup, unittest.TestCase,
|
||||
ImportHelper, TestHelper):
|
||||
def setUp(self):
|
||||
self.setup_beets()
|
||||
self.load_plugins('mbsubmit')
|
||||
self._create_import_dir(2)
|
||||
self._setup_import_session()
|
||||
self.matcher = AutotagStub().install()
|
||||
|
||||
def tearDown(self):
|
||||
self.unload_plugins()
|
||||
self.teardown_beets()
|
||||
|
||||
def test_xxxxprint_tracks_output(self):
|
||||
"""Test the output of the "print tracks" choice."""
|
||||
self.matcher.matching = AutotagStub.BAD
|
||||
|
||||
with capture_stdout() as output:
|
||||
with control_stdin('\n'.join(['p', 's'])):
|
||||
# Print tracks; Skip
|
||||
self.importer.run()
|
||||
|
||||
# manually build the string for comparing the output
|
||||
tracklist = ('Print tracks? '
|
||||
'01. Tag Title 1 - Tag Artist (0:01)\n'
|
||||
'02. Tag Title 2 - Tag Artist (0:01)')
|
||||
self.assertIn(tracklist, output.getvalue())
|
||||
|
||||
def test_xxprint_tracks_output_as_tracks(self):
|
||||
"""Test the output of the "print tracks" choice, as singletons."""
|
||||
self.matcher.matching = AutotagStub.BAD
|
||||
|
||||
with capture_stdout() as output:
|
||||
with control_stdin('\n'.join(['t', 's', 'p', 's'])):
|
||||
# as Tracks; Skip; Print tracks; Skip
|
||||
self.importer.run()
|
||||
|
||||
# manually build the string for comparing the output
|
||||
tracklist = ('Print tracks? '
|
||||
'02. Tag Title 2 - Tag Artist (0:01)')
|
||||
self.assertIn(tracklist, output.getvalue())
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
if __name__ == b'__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
Loading…
Reference in a new issue