tests: Don't depend on the order of random sequences

This commit is contained in:
Stein Magnus Jodal 2014-02-28 01:17:14 +01:00
parent 590ce19148
commit 061ff00a39
2 changed files with 12 additions and 7 deletions

View File

@ -284,8 +284,9 @@ class LocalLibraryProviderTest(unittest.TestCase):
# Matches on track album artists
result = self.library.find_exact(any=['artist3'])
self.assertEqual(
list(result[0].tracks), [self.tracks[3], self.tracks[2]])
self.assertEqual(len(result[0].tracks), 2)
self.assertIn(self.tracks[2], result[0].tracks)
self.assertIn(self.tracks[3], result[0].tracks)
# Matches on track composer
result = self.library.find_exact(any=['artist5'])
@ -502,8 +503,9 @@ class LocalLibraryProviderTest(unittest.TestCase):
# Matches on track album artists
result = self.library.search(any=['Tist3'])
self.assertEqual(
list(result[0].tracks), [self.tracks[3], self.tracks[2]])
self.assertEqual(len(result[0].tracks), 2)
self.assertIn(self.tracks[2], result[0].tracks)
self.assertIn(self.tracks[3], result[0].tracks)
# Matches on track genre
result = self.library.search(any=['Enre1'])

View File

@ -91,10 +91,13 @@ class JsonRpcSerializationTest(JsonRpcTestBase):
self.jrw.handle_data.return_value = {'foo': models.Artist(name='bar')}
request = '[]'
response = self.jrw.handle_json(request)
response = json.loads(self.jrw.handle_json(request))
self.assertEqual(
response, '{"foo": {"__model__": "Artist", "name": "bar"}}')
self.assertIn('foo', response)
self.assertIn('__model__', response['foo'])
self.assertEqual(response['foo']['__model__'], 'Artist')
self.assertIn('name', response['foo'])
self.assertEqual(response['foo']['name'], 'bar')
def test_handle_json_returns_nothing_for_notices(self):
request = '{"jsonrpc": "2.0", "method": "core.get_uri_schemes"}'