Beispiel #1
0
def test_remove_subscription(fx_stages, fx_subscription):
    a, b = fx_stages
    with a:
        s = SubscriptionList()
        s.add(fx_subscription)
        a.subscriptions = s
    with a:
        assert fx_subscription in a.subscriptions
    with b:
        assert fx_subscription in b.subscriptions
    added = Subscription(
        label='Added',
        feed_uri='http://example.com/atom.xml',
        alternate_uri='http://example.com/'
    )
    with a:
        a_s = a.subscriptions
        a_s.remove(fx_subscription)
        a.subscriptions = a_s
        with b:
            b_s = b.subscriptions
            b_s.add(added)
            b.subscriptions = b_s
    with a:
        assert added in a.subscriptions
        assert fx_subscription not in a.subscriptions
    with b:
        assert added in b.subscriptions
        assert fx_subscription not in b.subscriptions
Beispiel #2
0
def test_subscription_list_contains_category(fx_categorized_subscription_list):
    subs = fx_categorized_subscription_list
    expected = {
        Category(label='Game'): frozenset([
            Subscription(label='valve', feed_uri='http://valve.com/'),
            Subscription(label='nintendo', feed_uri='http://nintendo.com/')
        ]),
        Category(label='Music'): frozenset([
            Subscription(label='capsule',
                         feed_uri='http://www.capsule-web.com/')
        ])
    }
    assert frozenset(subs) == frozenset(expected)
    for outline in subs:
        print(outline.label)
        assert outline.type == 'category'
        print(list(outline))
        assert frozenset(outline) == expected[outline]
Beispiel #3
0
def test_subscription_set_categories_subscriptions():
    subs = SubscriptionList()
    subs.add(Category(label='Category A'))
    subs.add(Subscription(label='Subscription A', feed_uri='http://feeda.com/'))
    subs.add(Category(label='Category B'))
    subs.add(Subscription(label='Subscription B', feed_uri='http://feedb.com/'))
    subs.add(Category(label='Category C'))
    subs.add(Subscription(label='Subscription C', feed_uri='http://feedc.com/'))
    assert subs.categories == {
        'Category A': Category(label='Category A'),
        'Category B': Category(label='Category B'),
        'Category C': Category(label='Category C')
    }
    assert subs.subscriptions == frozenset([
        Subscription(label='Subscription A', feed_uri='http://feeda.com/'),
        Subscription(label='Subscription B', feed_uri='http://feedb.com/'),
        Subscription(label='Subscription C', feed_uri='http://feedc.com/')
    ])
Beispiel #4
0
def test_subscription_list_category_update(fx_categorized_subscription_list):
    subs = fx_categorized_subscription_list
    category = next(iter(subs))
    category.add(Subscription(label='added', feed_uri='http://example.com/'))
    assert len(category) == 3
    assert len(next(iter(subs))) == 3
Beispiel #5
0
def test_subscription_list_iter(fx_subscription_list):
    assert frozenset(fx_subscription_list) == frozenset([
        Subscription(label='CNET News.com',
                     feed_uri='http://news.com/2547-1_3-0-5.xml'),
        Subscription(label='test.com', feed_uri='http://test.com/')
    ])
Beispiel #6
0
def fx_subscription():
    return Subscription(label='Title',
                        feed_uri='http://example.com/rss.xml',
                        alternate_uri='http://example.com/')