예제 #1
0
 def setUp(self):
     self.sermon_audio_api = SermonAudioAPI('', '')
     self.speaker_name = 'David Whitcomb'
     self.member_id = 'communitybapt'
     self.sermon_id = '328131022290'
예제 #2
0
class TestSequenceFunctions(unittest.TestCase):

    def setUp(self):
        self.sermon_audio_api = SermonAudioAPI('', '')
        self.speaker_name = 'David Whitcomb'
        self.member_id = 'communitybapt'
        self.sermon_id = '328131022290'
        
    def _result_items_should_be_sermon(self, result):
        if len(result) > 0:
            self.assertEqual(str(result[0].__class__), 'suds.sudsobject.Sermon', 'Should be a suds.sudsobject.Sermon')
        
    def _result_should_be_list(self, result):
        self.assertEqual(result.__class__, [].__class__, 'Result should be a list')
        
    def _should_be_single_sermon(self, result):
        self.assertEqual(str(result.__class__), 'suds.sudsobject.SermonSingle', 'Should be suds.sudsobject.SermonSingle')
    
    def test_get_sermon_list(self):
        result = self.sermon_audio_api.get_sermon_list('', '')
        
        self.assertEqual(result, [], 'Result should be empty list. This may have failed because you did not specify a username and password in the setup method')
        
        result = self.sermon_audio_api.get_sermon_list('year', '2012')
        
        self._result_should_be_list(result)
        
        self._result_items_should_be_sermon(result)
        
    def test_get_sermon_info(self):
        result = self.sermon_audio_api.get_sermon_info('')
        
        self.assertEqual(result, [], 'Result should be empty list. This may have failed because you did not specify a username and password in the setup method')
        
        result = self.sermon_audio_api.get_sermon_info(self.sermon_id)
        
        self._should_be_single_sermon(result)
    
    def test_newest_sermons_by_speaker(self):
        result = self.sermon_audio_api.newest_sermons_by_speaker('')
        self.assertEqual(result, [], 'There should be no sermons')
        
        result = self.sermon_audio_api.newest_sermons_by_speaker(self.speaker_name)
        
        self._result_should_be_list(result)
        
        self._result_items_should_be_sermon(result)
        
        
    def test_newest_sermons_by_member_id(self):
        
        result = self.sermon_audio_api.newest_sermons_by_member_id(self.member_id)
        
        self._result_should_be_list(result)
        
        self._result_items_should_be_sermon(result)
        
    def test_get_event_types(self):
        result = self.sermon_audio_api.get_event_types()
        
        self._result_should_be_list(result)
        
    def test_get_languages(self):
        result = self.sermon_audio_api.get_languages()
        
        self._result_should_be_list(result)
        
    def test_get_newest_series_by_member_id(self):
        result = self.sermon_audio_api.get_newest_series_by_member_id(self.member_id)
        
        self._result_should_be_list(result)
        
    def test_get_series_by_member_id(self):
        result = self.sermon_audio_api.get_series_by_member_id(self.member_id)
        
        self._result_should_be_list(result)
        
    def test_get_speakers_by_member_id(self):
        result = self.sermon_audio_api.get_speakers_by_member_id(self.member_id)
        
        self._result_should_be_list(result)
        
    def test_get_speakers_by_keyword(self):
        result = self.sermon_audio_api.get_speakers_by_keyword('love')
        
        self._result_should_be_list(result)
        
    def test_get_favorite_broadcasters(self):        
        self.assertRaises(Exception, self.sermon_audio_api.get_favorite_broadcasters())
        
    def test_get_favorite_sermons(self):
        self.assertRaises(Exception, self.sermon_audio_api.get_favorite_sermons())
        
    def test_get_favorite_speakers(self):
        self.assertRaises(Exception, self.sermon_audio_api.get_favorite_speakers())
        
    def test_submit_sermon(self):
        self.assertRaises(Exception, self.sermon_audio_api.submit_sermon())
        
    def test_update_sermon(self):
        self.assertRaises(Exception, self.sermon_audio_api.submit_sermon())