def test_subscribe(self):
        self.mock.StubOutWithMock(PodcastChannel, 'subscribe')
        PodcastChannel.subscribe('newurl.com')

        self.mock.ReplayAll()
        call_command('podcast', 'newurl.com', subscribe=True,
                     stdout=self.stdout, stderr=self.stderr)
        self.mock.VerifyAll()

        self.assertEqual(len(self.stderr.lines), 0)
        self.assertEqual(len(self.stdout.lines), 0)
Beispiel #2
0
    def test_subscribe(self):
        self.mock.StubOutWithMock(PodcastChannel, 'subscribe')
        PodcastChannel.subscribe('newurl.com')

        self.mock.ReplayAll()
        call_command('podcast',
                     'newurl.com',
                     subscribe=True,
                     stdout=self.stdout,
                     stderr=self.stderr)
        self.mock.VerifyAll()

        self.assertEqual(len(self.stderr.lines), 0)
        self.assertEqual(len(self.stdout.lines), 0)
    def test_subscribe_failed_request(self):
        self.mock.StubOutWithMock(PodcastChannel, 'subscribe')
        PodcastChannel.subscribe('newurl.com').AndRaise(
            requests.exceptions.RequestException)

        self.mock.ReplayAll()
        call_command('podcast', 'newurl.com', subscribe=True,
                     stdout=self.stdout, stderr=self.stderr)
        self.mock.VerifyAll()

        self.assertEqual(len(self.stderr.lines), 1)
        self.assertEqual(len(self.stdout.lines), 0)
        self.assertEqual(
            self.stderr.lines[0],
            '"newurl.com" is not a valid url. Skipping.\n')
Beispiel #4
0
    def test_subscribe_failed_request(self):
        self.mock.StubOutWithMock(PodcastChannel, 'subscribe')
        PodcastChannel.subscribe('newurl.com').AndRaise(
            requests.exceptions.RequestException)

        self.mock.ReplayAll()
        call_command('podcast',
                     'newurl.com',
                     subscribe=True,
                     stdout=self.stdout,
                     stderr=self.stderr)
        self.mock.VerifyAll()

        self.assertEqual(len(self.stderr.lines), 1)
        self.assertEqual(len(self.stdout.lines), 0)
        self.assertEqual(self.stderr.lines[0],
                         '"newurl.com" is not a valid url. Skipping.\n')
    def test_subscribe(self):
        self.mock.StubOutWithMock(PodcastChannel, 'update_channel')
        PodcastChannel.update_channel()

        self.mock.ReplayAll()
        sub_channel = PodcastChannel.subscribe('http://test.com')
        self.mock.VerifyAll()

        self.assertEqual(sub_channel.url, 'http://test.com')
    def test_subscribe(self):
        self.mock.StubOutWithMock(PodcastChannel, 'update_channel')
        PodcastChannel.update_channel()

        self.mock.ReplayAll()
        sub_channel = PodcastChannel.subscribe('http://test.com')
        self.mock.VerifyAll()

        self.assertEqual(sub_channel.url, 'http://test.com')
Beispiel #7
0
 def subscribe(self, *args, **options):
     for url in args:
         try:
             PodcastChannel.subscribe(url)
         except RequestException:
             self.stderr.write('"%s" is not a valid url. Skipping.' % url)
Beispiel #8
0
 def subscribe(self, *args, **options):
     for url in args:
         try:
             PodcastChannel.subscribe(url)
         except RequestException:
             self.stderr.write('"%s" is not a valid url. Skipping.' % url)