mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 01:25:47 +01:00
first try at using patch
This commit is contained in:
parent
d748cc7744
commit
d727149dd4
1 changed files with 16 additions and 12 deletions
|
|
@ -19,13 +19,15 @@ from __future__ import division, absolute_import, print_function
|
|||
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from test.helper import TestHelper
|
||||
from mock import Mock
|
||||
import musicbrainzngs
|
||||
#from mock import Mock
|
||||
#import musicbrainzngs
|
||||
|
||||
from beets.library import Item
|
||||
from beetsplug import parentwork
|
||||
|
||||
|
||||
work = {'work': {'id': '1',
|
||||
'title': 'work',
|
||||
'work-relation-list': [{'type': 'parts',
|
||||
|
|
@ -56,15 +58,6 @@ p_work = {'work': {'id': '3',
|
|||
'composer, random'}}]}}
|
||||
|
||||
|
||||
def mock_workid_response(mbid, includes):
|
||||
if mbid == '1':
|
||||
return work
|
||||
elif mbid == '2':
|
||||
return dp_work
|
||||
elif mbid == '3':
|
||||
return p_work
|
||||
|
||||
|
||||
class ParentWorkIntegrationTest(unittest.TestCase, TestHelper):
|
||||
def setUp(self):
|
||||
"""Set up configuration"""
|
||||
|
|
@ -145,11 +138,22 @@ class ParentWorkTest(unittest.TestCase, TestHelper):
|
|||
"""Set up configuration"""
|
||||
self.setup_beets()
|
||||
self.load_plugins('parentwork')
|
||||
musicbrainzngs.get_work_by_id = Mock(side_effect=mock_workid_response)
|
||||
self.patcher1 = patch('musicbrainzngs.get_work_by_id')
|
||||
mock_workid_response = self.patcher1.start()
|
||||
#musicbrainzngs.get_work_by_id = Mock(side_effect=mock_workid_response)
|
||||
|
||||
def tearDown(self):
|
||||
self.unload_plugins()
|
||||
self.teardown_beets()
|
||||
self.patcher1.stop()
|
||||
|
||||
def mock_workid_response(self, mbid, includes):
|
||||
if mbid == '1':
|
||||
return work
|
||||
elif mbid == '2':
|
||||
return dp_work
|
||||
elif mbid == '3':
|
||||
return p_work
|
||||
|
||||
def test_normal_case(self):
|
||||
item = Item(path='/file', mb_workid='1', parentwork_workid_current='1')
|
||||
|
|
|
|||
Loading…
Reference in a new issue