make tests both with MB and without

This commit is contained in:
soergeld 2020-07-13 21:34:24 +02:00
parent 94dd7cee70
commit 58b11d9d3c

View file

@ -73,9 +73,6 @@ class ParentWorkTest(unittest.TestCase, TestHelper):
@mock.patch('musicbrainzngs.get_work_by_id',
side_effect=mock_workid_response)
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_normal_case(self):
item = Item(path='/file',
mb_workid='1')
@ -87,9 +84,6 @@ class ParentWorkTest(unittest.TestCase, TestHelper):
self.assertEqual(item['mb_parentworkid'],
'3')
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_force(self):
self.config['parentwork']['force'] = True
item = Item(path='/file',
@ -103,9 +97,6 @@ class ParentWorkTest(unittest.TestCase, TestHelper):
self.assertEqual(item['mb_parentworkid'],
'3')
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_no_force(self):
self.config['parentwork']['force'] = True
item = Item(path='/file', mb_workid='1', mb_parentworkid=u'XXX')
@ -119,15 +110,70 @@ class ParentWorkTest(unittest.TestCase, TestHelper):
# test different cases, still with Matthew Passion Ouverture or Mozart
# requiem
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_direct_parent_work(self):
self.assertEqual('2',
parentwork.direct_parent_id('1')[0])
self.assertEqual('3',
parentwork.work_parent_id('1')[0])
# test how it works with real musicbrainz data
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_normal_case_real(self):
item = Item(path='/file',
mb_workid=u'e27bda6e-531e-36d3-9cd7-b8ebc18e8c53')
item.add(self.lib)
self.run_command('parentwork')
item.load()
self.assertEqual(item['mb_parentworkid'],
u'32c8943f-1b27-3a23-8660-4567f4847c94')
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_force_real(self):
self.config['parentwork']['force'] = True
item = Item(path='/file',
mb_workid=u'e27bda6e-531e-36d3-9cd7-b8ebc18e8c53',
mb_parentworkid=u'XXX')
item.add(self.lib)
self.run_command('parentwork')
item.load()
self.assertEqual(item['mb_parentworkid'],
u'32c8943f-1b27-3a23-8660-4567f4847c94')
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_no_force_real(self):
self.config['parentwork']['force'] = True
item = Item(path='/file', mb_workid=u'e27bda6e-531e-36d3-9cd7-\
b8ebc18e8c53', mb_parentworkid=u'XXX')
item.add(self.lib)
self.run_command('parentwork')
item.load()
self.assertEqual(item['mb_parentworkid'], u'XXX')
# test different cases, still with Matthew Passion Ouverture or Mozart
# requiem
@unittest.skipUnless(
os.environ.get('INTEGRATION_TEST', '0') == '1',
'integration testing not enabled')
def test_direct_parent_work_real(self):
mb_workid = u'2e4a3668-458d-3b2a-8be2-0b08e0d8243a'
self.assertEqual(u'f04b42df-7251-4d86-a5ee-67cfa49580d1',
parentwork.direct_parent_id(mb_workid)[0])
self.assertEqual(u'45afb3b2-18ac-4187-bc72-beb1b1c194ba',
parentwork.work_parent_id(mb_workid)[0])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)