Ejemplo n.º 1
0
    def test_email(self):
        """Test email notifications."""
        email_notifier = EmailNotifier()

        # Per-show-email notifications were added early on and utilized a different format than the other notifiers.
        # Therefore, to test properly (and ensure backwards compatibility), this routine will test shows that use
        # both the old and the new storage methodology
        legacy_test_emails = "[email protected],[email protected],[email protected]"
        test_emails = "[email protected],[email protected],[email protected]"

        for show in self.legacy_shows:
            showid = self._get_showid_by_showname(show.name)
            self.mydb.action("UPDATE tv_shows SET notify_list = ? WHERE show_id = ?", [legacy_test_emails, showid])

        for show in self.shows:
            showid = self._get_showid_by_showname(show.name)
            Home.saveShowNotifyList(indexername='tvdb', seriesid=showid, emails=test_emails)

        # Now, iterate through all shows using the email list generation routines that are used in the notifier proper
        shows = self.legacy_shows + self.shows
        for show in shows:
            for episode in show.episodes:
                ep_name = ss(episode._format_pattern('%SN - %Sx%0E - %EN - ') + episode.quality)  # pylint: disable=protected-access
                show_name = email_notifier._parseEp(ep_name)  # pylint: disable=protected-access
                recipients = email_notifier._generate_recipients(show_name)  # pylint: disable=protected-access
                self._debug_spew("- Email Notifications for " + show.name + " (episode: " + episode.name + ") will be sent to:")
                for email in recipients:
                    self._debug_spew("-- " + email.strip())
                self._debug_spew("\n\r")

        return True
Ejemplo n.º 2
0
def test__parse_name(p):
    # Given
    ep_name = p['ep_name']
    expected = p['expected']

    # When
    actual = Notifier._parse_name(ep_name)

    # Then
    assert actual == expected
Ejemplo n.º 3
0
def test__parse_name(p):
    # Given
    ep_name = p['ep_name']
    expected = p['expected']

    # When
    actual = Notifier._parse_name(ep_name)

    # Then
    assert actual == expected
Ejemplo n.º 4
0
    def test_email(self):
        """Test email notifications."""
        email_notifier = EmailNotifier()

        # Per-show-email notifications were added early on and utilized a different format than the other notifiers.
        # Therefore, to test properly (and ensure backwards compatibility), this routine will test shows that use
        # both the old and the new storage methodology
        legacy_test_emails = "[email protected],[email protected],[email protected]"
        test_emails = "[email protected],[email protected],[email protected]"

        for show in self.legacy_shows:
            showid = self._get_showid_by_showname(show.name)
            self.mydb.action(
                "UPDATE tv_shows SET notify_list = ? WHERE show_id = ?",
                [legacy_test_emails, showid])

        for show in self.shows:
            showid = self._get_showid_by_showname(show.name)
            Home.saveShowNotifyList(indexername='tvdb',
                                    seriesid=showid,
                                    emails=test_emails)

        # Now, iterate through all shows using the email list generation routines that are used in the notifier proper
        shows = self.legacy_shows + self.shows
        for show in shows:
            for episode in show.episodes:
                ep_name = ss(
                    episode._format_pattern('%SN - %Sx%0E - %EN - ') +
                    episode.quality)  # pylint: disable=protected-access
                show_name = email_notifier._parseEp(ep_name)  # pylint: disable=protected-access
                recipients = email_notifier._generate_recipients(show_name)  # pylint: disable=protected-access
                self._debug_spew("- Email Notifications for " + show.name +
                                 " (episode: " + episode.name +
                                 ") will be sent to:")
                for email in recipients:
                    self._debug_spew("-- " + email.strip())
                self._debug_spew("\n\r")

        return True
Ejemplo n.º 5
0
def test__generate_recipients(p, app_config, monkeypatch_function_return):
    # Given
    show = p['show']
    expected = p['expected']

    app_config('EMAIL_LIST', p['EMAIL_LIST'])
    if show:
        monkeypatch_function_return(p['mocks'])

    # When
    actual = Notifier._generate_recipients(show)

    # Then
    assert actual == expected
Ejemplo n.º 6
0
def test__generate_recipients(p, app_config, monkeypatch_function_return):
    # Given
    show = p['show']
    expected = p['expected']

    app_config('EMAIL_LIST', p['EMAIL_LIST'])
    if show:
        monkeypatch_function_return(p['mocks'])

    # When
    actual = Notifier._generate_recipients(show)

    # Then
    assert actual == expected
Ejemplo n.º 7
0
def test__generate_recipients(p, app_config, monkeypatch_function_return,
                              create_tvshow):
    # Given
    show = p['show']
    show_obj = None
    if show:
        show_obj = create_tvshow(indexerid=12, name=show)

    expected = p['expected']

    app_config('EMAIL_LIST', p['EMAIL_LIST'])
    if show:
        monkeypatch_function_return(p['mocks'])

    # When
    actual = Notifier._generate_recipients(show_obj)

    # Then
    assert actual == expected