예제 #1
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)
예제 #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)
예제 #3
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')
예제 #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')
예제 #5
0
    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')
예제 #6
0
    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')
예제 #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)
예제 #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)