Skip to content

Commit

Permalink
Replace assert_ with assertIn or assertTrue.
Browse files Browse the repository at this point in the history
  • Loading branch information
auouymous committed Nov 3, 2023
1 parent c6b978c commit 65af6f0
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions mygpoclient/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def test_toDictionary_containsMandatoryAttributes(self):
action = api.EpisodeAction(FEED_URL_1, EPISODE_URL_1, 'play')
dictionary = action.to_dictionary()
self.assertEqual(len(list(dictionary.keys())), 3)
self.assert_('podcast' in dictionary)
self.assert_('episode' in dictionary)
self.assert_('action' in dictionary)
self.assertIn('podcast', dictionary)
self.assertIn('episode', dictionary)
self.assertIn('action', dictionary)
self.assertEqual(dictionary['podcast'], FEED_URL_1)
self.assertEqual(dictionary['episode'], EPISODE_URL_1)
self.assertEqual(dictionary['action'], 'play')
Expand All @@ -169,14 +169,14 @@ def test_toDictionary_containsAllAttributes(self):
self.VALID_POSITION, self.VALID_TOTAL)
dictionary = action.to_dictionary()
self.assertEqual(len(list(dictionary.keys())), 8)
self.assert_('podcast' in dictionary)
self.assert_('episode' in dictionary)
self.assert_('action' in dictionary)
self.assert_('device' in dictionary)
self.assert_('timestamp' in dictionary)
self.assert_('started' in dictionary)
self.assert_('position' in dictionary)
self.assert_('total' in dictionary)
self.assertIn('podcast', dictionary)
self.assertIn('episode', dictionary)
self.assertIn('action', dictionary)
self.assertIn('device', dictionary)
self.assertIn('timestamp', dictionary)
self.assertIn('started', dictionary)
self.assertIn('position', dictionary)
self.assertIn('total', dictionary)
self.assertEqual(dictionary['podcast'], FEED_URL_3)
self.assertEqual(dictionary['episode'], EPISODE_URL_4)
self.assertEqual(dictionary['action'], 'play')
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_putSubscriptions_withPodcastDevice(self):
self.client.put_subscriptions(
device, self.ADD), True)
self.assert_http_request_count(1)
self.assert_(self.has_put_json_data(self.ADD))
self.assertTrue(self.has_put_json_data(self.ADD))

def test_updateSubscriptions_raisesValueError_onInvalidAddList(self):
self.assertRaises(ValueError,
Expand Down Expand Up @@ -334,12 +334,12 @@ def test_updateSubscriptions_returnsUpdateResult(self):
result = self.client.update_subscriptions(DEVICE_ID_1,
self.ADD, self.REMOVE)
# result is a UpdateResult object
self.assert_(hasattr(result, 'since'))
self.assert_(hasattr(result, 'update_urls'))
self.assertTrue(hasattr(result, 'since'))
self.assertTrue(hasattr(result, 'update_urls'))
self.assertEqual(result.since, self.SINCE)
self.assertEqual(result.update_urls, update_urls_expected)
self.assert_http_request_count(1)
self.assert_(self.has_posted_json_data(self.ADD_REMOVE_AS_JSON_UPLOAD))
self.assertTrue(self.has_posted_json_data(self.ADD_REMOVE_AS_JSON_UPLOAD))

def test_pullSubscriptions_raisesInvalidResponse_onEmptyResponse(self):
self.set_http_response_value(b'')
Expand Down Expand Up @@ -473,7 +473,7 @@ def test_uploadEpisodeActions_returnsTimestamp(self):
result = self.client.upload_episode_actions(self.ACTIONS)
self.assertEqual(result, self.SINCE)
self.assert_http_request_count(1)
self.assert_(self.has_posted_json_data(self.ACTIONS_AS_JSON_UPLOAD))
self.assertTrue(self.has_posted_json_data(self.ACTIONS_AS_JSON_UPLOAD))

def test_downloadEpisodeActions_raisesInvalidResponse_onEmptyResponse(
self):
Expand Down Expand Up @@ -551,31 +551,31 @@ def test_updateDeviceSettings_withNothing(self):
result = self.client.update_device_settings(DEVICE_ID_1)
self.assertEqual(result, True)
self.assert_http_request_count(1)
self.assert_(self.has_posted_json_data({}))
self.assertTrue(self.has_posted_json_data({}))

def test_updateDeviceSettings_withCaption(self):
self.set_http_response_value(b'')
result = self.client.update_device_settings(DEVICE_ID_1,
caption='Poodonkis')
self.assertEqual(result, True)
self.assert_http_request_count(1)
self.assert_(self.has_posted_json_data({'caption': 'Poodonkis'}))
self.assertTrue(self.has_posted_json_data({'caption': 'Poodonkis'}))

def test_updateDeviceSettings_withType(self):
self.set_http_response_value(b'')
result = self.client.update_device_settings(DEVICE_ID_1,
type='desktop')
self.assertEqual(result, True)
self.assert_http_request_count(1)
self.assert_(self.has_posted_json_data({'type': 'desktop'}))
self.assertTrue(self.has_posted_json_data({'type': 'desktop'}))

def test_updateDeviceSettings_withCaptionAndType(self):
self.set_http_response_value(b'')
result = self.client.update_device_settings(DEVICE_ID_1,
'My Unit Testing Device', 'desktop')
self.assertEqual(result, True)
self.assert_http_request_count(1)
self.assert_(self.has_posted_json_data({
self.assertTrue(self.has_posted_json_data({
'caption': 'My Unit Testing Device',
'type': 'desktop'}))

Expand Down

0 comments on commit 65af6f0

Please sign in to comment.