mirror of
https://github.com/beetbox/beets.git
synced 2026-01-03 14:32:55 +01:00
Updated tests
This commit is contained in:
parent
4f0a2b78a3
commit
db5d21620b
1 changed files with 25 additions and 29 deletions
|
|
@ -21,7 +21,6 @@ from __future__ import division, absolute_import, print_function
|
|||
import unittest
|
||||
from test.helper import TestHelper
|
||||
|
||||
|
||||
class ExportPluginTest(unittest.TestCase, TestHelper):
|
||||
def setUp(self):
|
||||
self.setup_beets()
|
||||
|
|
@ -31,40 +30,37 @@ class ExportPluginTest(unittest.TestCase, TestHelper):
|
|||
self.unload_plugins()
|
||||
self.teardown_beets()
|
||||
|
||||
def test_json_output(self):
|
||||
item1, item2 = self.add_item_fixtures(count=2)
|
||||
item1.album = 'talbum'
|
||||
item1.artist = "tartist"
|
||||
item1.track = "ttrack"
|
||||
def execute_command(self, format_type, artist):
|
||||
options = ' -f %s -i "track,album" s'.format(format_type, artist)
|
||||
actual = self.run_with_output('export', options)
|
||||
return actual.replace(" ", "")
|
||||
|
||||
def create_item(self, album='talbum', artist='tartist', track='ttrack'):
|
||||
item1, = self.add_item_fixtures()
|
||||
item1.album = album
|
||||
item1.artist = artist
|
||||
item1.track = track
|
||||
item1.write()
|
||||
item1.store()
|
||||
options = '-f json -i "track,album" ' + item1.artist
|
||||
out = self.run_with_output('export', options)
|
||||
self.assertIn('"track": "' + item1.track + '"', out)
|
||||
self.assertIn('"album": "' + item1.album + '"', out)
|
||||
return item1
|
||||
|
||||
def test_json_output(self):
|
||||
item1 = self.create_item()
|
||||
actual = self.execute_command(format_type='json',artist=item1.artist)
|
||||
expected = '[{"track":%s,"album":%s}]'.format(item1.track,item1.album)
|
||||
self.assertIn(first=expected,second=actual,msg="export in JSON format failed")
|
||||
|
||||
def test_csv_output(self):
|
||||
item1, item2 = self.add_item_fixtures(count=2)
|
||||
item1.album = 'talbum'
|
||||
item1.artist = "tartist"
|
||||
item1.track = "ttrack"
|
||||
item1.write()
|
||||
item1.store()
|
||||
options = '-f csv -i "track,album" ' + item1.artist
|
||||
out = self.run_with_output('export', options)
|
||||
self.assertIn(item1.track + ',' + item1.album, out)
|
||||
item1 = self.create_item()
|
||||
actual = self.execute_command(format_type='json',artist=item1.artist)
|
||||
expected = 'track,album\n%s,%s'.format(item1.track,item1.album)
|
||||
self.assertIn(first=expected,second=actual,msg="export in CSV format failed")
|
||||
|
||||
def test_xml_output(self):
|
||||
item1, item2 = self.add_item_fixtures(count=2)
|
||||
item1.album = 'talbum'
|
||||
item1.artist = "tartist"
|
||||
item1.track = "ttrack"
|
||||
item1.write()
|
||||
item1.store()
|
||||
options = '-f xml -i "track,album" ' + item1.artist
|
||||
out = self.run_with_output('export', options)
|
||||
self.assertIn("<title>" + item1.track + "</title>", out)
|
||||
self.assertIn("<album>" + item1.album + "</album>", out)
|
||||
item1 = self.create_item()
|
||||
actual = self.execute_command(format_type='json',artist=item1.artist)
|
||||
expected = '<title>%s</title><album>%s</album>'.format(item1.track,item1.album)
|
||||
self.assertIn(first=expected,second=actual,msg="export in XML format failed")
|
||||
|
||||
|
||||
def suite():
|
||||
|
|
|
|||
Loading…
Reference in a new issue