def test_subscriptions_broken_no_body():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    with pytest.raises(SubscriptionsStructureError):
        mysubscriptions.load(my_dir + "/subscriptions/broken_no_body.xml")
        for generated in mysubscriptions.parse():
            pass
Example #2
0
def test_subscriptions_parse_feedparseerror():
    Feed.__init__ = mock.MagicMock(return_value=None)
    Feed.__init__.side_effect = FeedParseError()

    mysubscriptions = Subscriptions()
    mysubscriptions.load(my_dir + "/subscriptions/valid_complete.xml")
    for generated in mysubscriptions.parse():
        assert isinstance(generated[1], FeedParseError)
Example #3
0
def test_subscriptions_broken_no_outline():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    mysubscriptions.load(my_dir + "/subscriptions/broken_no_outline.xml")

    count = 0
    for generated in mysubscriptions.parse():
        count += 1
    assert count == 0
Example #4
0
def test_subscriptions_valid_no_head():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    mysubscriptions.load(my_dir + "/subscriptions/valid_no_head.xml")
    assert isinstance(mysubscriptions, Subscriptions)
    Feed.__init__.assert_any_call(url="http://feed1")
    Feed.__init__.assert_any_call(url="http://feed2")
    assert Feed.__init__.call_count == 2
    assert len(mysubscriptions.feeds) == 2
def test_subscriptions_valid_complete():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    mysubscriptions.load(my_dir + "/subscriptions/valid_complete.xml")
    for generated in mysubscriptions.parse():
        pass
    assert isinstance(mysubscriptions, Subscriptions)
    Feed.__init__.assert_any_call(url="http://feed1")
    Feed.__init__.assert_any_call(url="http://feed2")
    assert Feed.__init__.call_count == 2
    assert len(mysubscriptions.feeds) == 2
def test_subscriptions_broken_parse():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    with pytest.raises(SubscriptionsParseError):
        mysubscriptions.load(my_dir + "/subscriptions/broken_parse.xml")
def test_subscriptions_broken_nonexistant():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    with pytest.raises(SubscriptionsLoadError):
        mysubscriptions.load(my_dir + "/subscriptions/doesnt_exist")
def test_subscriptions_valid_minimal():
    mysubscriptions = Subscriptions()
    Feed.__init__ = mock.MagicMock(return_value=None)
    mysubscriptions.load(my_dir + "/subscriptions/valid_minimal.xml")
    assert isinstance(mysubscriptions, Subscriptions)
    assert len(mysubscriptions.feeds) == 0
def test_subscriptions_save_before_create():
    mysubscriptions = Subscriptions()
    with pytest.raises(SubscriptionsError):
        mysubscriptions.save(my_dir + "/subscriptions/saved_bad_temp.xml")