Пример #1
0
def test_person_str():
    assert text_type(Person(name='Hong Minhee')) == 'Hong Minhee'
    assert (text_type(
        Person(name='Hong Minhee',
               uri='http://dahlia.kr/')) == 'Hong Minhee <http://dahlia.kr/>')
    email = '\x6d\x69\x6e\x68\x65\x65\x40\x64\x61\x68\x6c\x69\x61\x2e\x6b\x72'
    assert (text_type(Person(name='Hong Minhee',
                             email=email)) == 'Hong Minhee <' + email + '>')
    assert u('홍민희 <http://dahlia.kr/>') == text_type(
        Person(name=u('홍민희'), uri='http://dahlia.kr/', email=email))
Пример #2
0
def test_person_html():
    assert (Person(
        name='Hong "Test" Minhee').__html__() == 'Hong &quot;Test&quot; Minhee'
            )
    assert (Person(name='Hong Minhee', uri='http://dahlia.kr/').__html__() ==
            '<a href="http://dahlia.kr/">Hong Minhee</a>')
    email = '\x6d\x69\x6e\x68\x65\x65\x40\x64\x61\x68\x6c\x69\x61\x2e\x6b\x72'
    assert (Person(name='Hong Minhee',
                   email=email).__html__() == '<a href="mailto:' + email +
            '">Hong Minhee</a>')
    assert u('<a href="http://dahlia.kr/">홍민희</a>') == Person(
        name=u('홍민희'), uri='http://dahlia.kr/', email=email).__html__()
Пример #3
0
def fx_test_feeds():
    authors = [Person(name='vio')]
    feed = Feed(id='http://feedone.com/',
                authors=authors,
                title='Feed One',
                updated_at=datetime.datetime(2013,
                                             10,
                                             29,
                                             20,
                                             55,
                                             30,
                                             tzinfo=utc))
    updated_feed = Feed(id='http://feedone.com/',
                        authors=authors,
                        title=Text(value='Feed One'),
                        updated_at=datetime.datetime(2013,
                                                     10,
                                                     30,
                                                     20,
                                                     55,
                                                     30,
                                                     tzinfo=utc))
    entry = Entry(id='http://feedone.com/1',
                  authors=authors,
                  title=Text(value='Test Entry'),
                  updated_at=datetime.datetime(2013,
                                               10,
                                               30,
                                               20,
                                               55,
                                               30,
                                               tzinfo=utc))
    updated_feed.entries.append(entry)
    return feed, updated_feed
Пример #4
0
def initialize_subscriptions():
    def form(field):
        value = request.form.get(field)
        return value and value.strip()

    owner_name = form('owner_name')
    owner_email = form('owner_email')
    owner_uri = form('owner_uri')
    if owner_name:
        owner = Person(name=owner_name,
                       email=owner_email or None,
                       uri=owner_uri or None)
    else:
        owner = None
    title = form('title')
    with g.stage:
        subscriptions = g.stage.subscriptions
        if subscriptions is None:
            subscriptions = get_default_subscriptions()
            subscriptions.owner = None
            subscriptions.title = None
        if owner:
            subscriptions.owner = owner
        if title:
            subscriptions.title = title
        g.stage.subscriptions = subscriptions
    return redirect(url_for('.subscriptions'))
Пример #5
0
def test_feed_read(fx_feed):
    feed = fx_feed
    assert feed.title == Text(value='Example Feed')
    link = feed.links[0]
    assert isinstance(link, Link)
    assert link.relation == 'alternate'
    assert link.uri == 'http://example.org/'
    assert len(feed.links) == 1
    assert feed.updated_at == datetime.datetime(2003,
                                                12,
                                                13,
                                                18,
                                                30,
                                                2,
                                                tzinfo=utc)
    authors = feed.authors
    assert isinstance(authors[0], Person)
    assert authors[0].name == 'John Doe'
    assert isinstance(authors[1], Person)
    assert authors[1].name == 'Jane Doe'
    assert len(feed.authors) == 2
    assert feed.id == 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6'
    categories = feed.categories
    assert isinstance(categories[0], Category)
    assert categories[0].term == 'technology'
    assert isinstance(categories[1], Category)
    assert categories[1].term == 'business'
    assert len(categories) == 2
    assert feed.rights == Text(value='Public Domain')
    entries = feed.entries
    assert isinstance(entries[0], Entry)
    assert entries[0].title == Text(value='Atom-Powered Robots Run Amok')
    assert (list(entries[0].links) == [
        Link(uri='http://example.org/2003/12/13/atom03')
    ])
    assert entries[0].id == 'urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a'
    assert entries[0].updated_at == datetime.datetime(2003,
                                                      12,
                                                      13,
                                                      18,
                                                      30,
                                                      2,
                                                      tzinfo=utc)
    assert entries[0].summary == Text(value='Some text.')
    assert list(entries[0].authors) == [Person(name='Jane Doe')]
    assert isinstance(entries[1], Entry)
    assert entries[1].title == Text(value='Danger, Will Robinson!')
    assert (list(
        entries[1].links) == [Link(uri='http://example.org/2003/12/13/lost')])
    assert entries[1].id == 'urn:uuid:b12f2c10-ffc1-11d9-8cd6-0800200c9a66'
    assert entries[1].updated_at == datetime.datetime(2003,
                                                      12,
                                                      13,
                                                      18,
                                                      30,
                                                      2,
                                                      tzinfo=utc)
    assert entries[1].summary == Text(value="Don't Panic!")
    assert len(entries) == 2
Пример #6
0
def test_no_head_set_owner(fx_headless_subscription_list):
    owner = Person(name='Earth Reader Team',
                   email='earthreader'
                   '@'
                   'librelist.com',
                   uri='http://earthreader.org/')
    fx_headless_subscription_list.owner = owner
    assert fx_headless_subscription_list.owner == owner
    assert fx_headless_subscription_list.head.owner_name == owner.name
    assert fx_headless_subscription_list.head.owner_email == owner.email
    assert fx_headless_subscription_list.head.owner_uri == owner.uri
Пример #7
0
def test_subscription_list_owner(fx_subscription_list):
    assert fx_subscription_list.head.owner_name == 'Earth Reader Team'
    assert (fx_subscription_list.head.owner_email ==
            'earthreader' '@' 'librelist.com')
    assert fx_subscription_list.head.owner_uri == 'http://earthreader.org/'
    assert fx_subscription_list.owner == Person(
        name='Earth Reader Team',
        email='earthreader' '@' 'librelist.com',
        uri='http://earthreader.org/'
    )
    fx_subscription_list.owner = Person(
        name='Hong Minhee',
        email='minhee' '@' 'dahlia.kr',
        uri='http://dahlia.kr/'
    )
    assert fx_subscription_list.head.owner_name == 'Hong Minhee'
    assert fx_subscription_list.head.owner_email == 'minhee' '@' 'dahlia.kr'
    assert fx_subscription_list.head.owner_uri == 'http://dahlia.kr/'
    fx_subscription_list.owner = None
    assert fx_subscription_list.owner is None
    assert fx_subscription_list.head.owner_name is None
    assert fx_subscription_list.head.owner_email is None
    assert fx_subscription_list.head.owner_uri is None
Пример #8
0
def initialize_subscriptions_form():
    current_user = get_current_user()
    default_owner = Person(name=current_user.nickname(),
                           email=current_user.email())
    default_title = None
    with g.stage:
        subscriptions = g.stage.subscriptions
        if subscriptions is not None:
            default_owner = subscriptions.owner
            default_title = subscriptions.title
    default_title_format = u'{name}\u2019s Subscriptions'
    if default_title is None:
        default_title = default_title_format.format(name=default_owner.name)
    return render_template('reader/initialize_subscriptions_form.html',
                           default_title_format=default_title_format,
                           default_owner=default_owner,
                           default_title=default_title)
Пример #9
0
def test_get_default_subscriptions(fx_opener):
    subs = get_default_subscriptions('http://blogroll.com/web/')
    assert subs.owner == Person(name='Earth Reader Team',
                                email='*****@*****.**',
                                uri='http://earthreader.org/')
    assert len(subs) == 1
    sub = next(iter(subs))
    assert sub.label == 'Earth Reader Blog'
    assert sub.feed_uri == 'http://blog.earthreader.org/index.xml'
    assert sub.alternate_uri == 'http://blog.earthreader.org/'
    assert sub.created_at == datetime.datetime(2013,
                                               10,
                                               29,
                                               15,
                                               30,
                                               tzinfo=utc)
    subs2 = get_default_subscriptions('http://blogroll.com/web/feeds.xml')
    assert subs2.owner == subs.owner
    assert frozenset(subs2) == frozenset(subs)
Пример #10
0
def fx_filtering_entries(fx_test_stage):
    authors = [Person(name='vio')]
    now = datetime.datetime(2013, 10, 30, 20, 55, 30, tzinfo=utc)
    feed = Feed(id='http://feedone.com/feed/atom/', authors=authors,
                title=Text(value='Feed One'),
                updated_at=now)
    for i in range(10):
        feed.entries.append(
            Entry(id='http://feedone.com/feed/atom/' + str(i) + '/',
                  authors=authors,
                  title=Text(value=str(i + 1)),
                  updated_at=now + datetime.timedelta(days=1) * i)
        )
    for i in range(5):
        feed.entries[i].read = Mark(marked=True, updated_at=now)
    for i in range(3, 7):
        feed.entries[i].starred = Mark(marked=True, updated_at=now)
    with fx_test_stage as stage:
        stage.feeds[get_hash('http://feedone.com/feed/atom/')] = feed
        stage.subscriptions = read(SubscriptionList, opml_for_filtering)
Пример #11
0
def xmls_for_next(request, fx_test_stage):
    opml = '''
    <opml version="1.0">
      <head>
        <title>test opml</title>
      </head>
      <body>
        <outline text="categoryone" title="categoryone">
            <outline type="atom" text="Feed One" title="Feed One"
            xmlUrl="http://feedone.com/" />
            <outline type="atom" text="Feed Two" title="Feed Two"
            xmlUrl="http://feedtwo.com/" />
        </outline>
        <outline type="atom" text="Feed Three" title="Feed Three"
        xmlUrl="http://feedthree.com/" />
        <outline type="atom" text="Feed Four" title="Feed Three"
        xmlUrl="http://feedthree.com/" />
      </body>
    </opml>
    '''
    authors = [Person(name='vio')]
    feed_one = Feed(id='http://feedone.com/', authors=authors,
                    title=Text(value='Feed One'),
                    updated_at=datetime.datetime(2013, 10, 30, 20, 55, 30,
                                                 tzinfo=utc))
    feed_two = Feed(id='http://feedtwo.com/', authors=authors,
                    title=Text(value='Feed Two'),
                    updated_at=datetime.datetime(2013, 10, 30, 21, 55, 30,
                                                 tzinfo=utc))
    feed_three = Feed(id='http://feedthree.com/', authors=authors,
                      title=Text(value='Feed Three'),
                      updated_at=datetime.datetime(2013, 10, 30, 21, 55, 30,
                                                   tzinfo=utc))
    feed_four = Feed(id='http://feedfour.com/', authors=authors,
                     title=Text(value='Feed Four'),
                     updated_at=datetime.datetime(2013, 10, 30, 21, 55, 30,
                                                  tzinfo=utc))
    for i in range(25):
        feed_one.entries.append(
            Entry(id='http://feedone.com/' + str(24 - i),
                  authors=authors,
                  title=Text(value='Feed One: Entry ' + str(24 - i)),
                  updated_at=datetime.datetime(2013, 10, 30, 20, 55, 30,
                                               tzinfo=utc) +
                  datetime.timedelta(days=-1)*i)
        )
        feed_two.entries.append(
            Entry(id='http://feedtwo.com/' + str(24 - i),
                  authors=authors,
                  title=Text(value='Feed Two: Entry ' + str(24 - i)),
                  updated_at=datetime.datetime(2013, 10, 30, 19, 55, 30,
                                               tzinfo=utc) +
                  datetime.timedelta(days=-1)*i)
        )
    for i in range(20):
        feed_three.entries.append(
            Entry(id='http://feedthree.com/' + str(19 - i),
                  authors=authors,
                  title=Text(value='Feed Three: Entry ' + str(19 - i)),
                  updated_at=datetime.datetime(2013, 10, 30, 20, 55, 30,
                                               tzinfo=utc) +
                  datetime.timedelta(days=-1)*i)
        )
    for i in range(50):
        feed_four.entries.append(
            Entry(id='http://feedfour.com/' + str(49 - i),
                  authors=authors,
                  title=Text(value='Feed Four: Entry ' + str(49 - i)),
                  updated_at=datetime.datetime(2013, 10, 30, 20, 55, 30,
                                               tzinfo=utc) +
                  datetime.timedelta(days=-1)*i)
        )
    for i in range(5):
        feed_two.entries[i].read = True
        feed_two.entries[i+15].read = True
    for i in range(20, 50):
        feed_four.entries[i].read = True
    subscriptions = read(SubscriptionList, opml)
    with fx_test_stage as stage:
        stage.subscriptions = subscriptions
        stage.feeds[get_hash('http://feedone.com/')] = feed_one
        stage.feeds[get_hash('http://feedtwo.com/')] = feed_two
        stage.feeds[get_hash('http://feedthree.com/')] = feed_three
        stage.feeds[get_hash('http://feedfour.com/')] = feed_four