Ejemplo n.º 1
0
    def refresh(self, feed_id, database='default', num_posts=None):
        data = get_posts_data(feed_id, num_posts)
        if data:
            return self.update_posts(data, database)

        # no data returned. something wrong.
        return 0
Ejemplo n.º 2
0
    def refresh(self, feed_id, num_posts=None):
        posts = get_posts_data(feed_id, num_posts)
        if posts:
            return self.update_posts(feed_id, posts)

        # no data returned. something wrong.
        return None, None
Ejemplo n.º 3
0
    def refresh(self, feed_id, database='default', num_posts=None):
        data = get_posts_data(feed_id, num_posts)
        if data:
            return self.update_posts(data, database)

        # no data returned. something wrong.
        return 0
Ejemplo n.º 4
0
def test_get_posts_data():
    setup_responses()
    data = api.get_posts_data('firefox')
    assert data['wp_blog_slug'] == 'firefox'
    assert data['posts'][0]['tags'] == ['browser', 'fastest']
    assert not data['posts'][0]['featured_media']
    assert not data['posts'][1]['featured_media']
    assert data['posts'][2]['featured_media']['id'] == 75
    assert len(responses.calls) == 3
Ejemplo n.º 5
0
def test_get_posts_data():
    setup_responses()
    data = api.get_posts_data('firefox')
    assert data['wp_blog_slug'] == 'firefox'
    assert data['posts'][0]['tags'] == ['browser', 'fastest']
    assert not data['posts'][0]['featured_media']
    assert not data['posts'][1]['featured_media']
    assert data['posts'][2]['featured_media']['id'] == 75
    assert len(responses.calls) == 3
Ejemplo n.º 6
0
def test_get_posts_data():
    setup_responses()
    posts = api.get_posts_data("firefox")
    tags = api.get_feed_tags("firefox")
    for post in posts:
        post["tags"] = [tags[t] for t in post["tags"]]
        api.update_post_media("firefox", post)
    assert posts[0]["tags"] == ["browser", "fastest"]
    assert posts[0]["featured_media"] == {}
    assert posts[1]["featured_media"] == {}
    assert posts[2]["featured_media"]["id"] == 75
    assert len(responses.calls) == 4
Ejemplo n.º 7
0
def test_get_posts_data():
    setup_responses()
    posts = api.get_posts_data('firefox')
    tags = api.get_feed_tags('firefox')
    for post in posts:
        post['tags'] = [tags[t] for t in post['tags']]
        api.update_post_media('firefox', post)
    assert posts[0]['tags'] == ['browser', 'fastest']
    assert posts[0]['featured_media'] == {}
    assert posts[1]['featured_media'] == {}
    assert posts[2]['featured_media']['id'] == 75
    assert len(responses.calls) == 4
Ejemplo n.º 8
0
def test_get_posts_data():
    setup_responses()
    posts = api.get_posts_data('firefox')
    tags = api.get_feed_tags('firefox')
    for post in posts:
        post['tags'] = [tags[t] for t in post['tags']]
        api.update_post_media('firefox', post)
    assert posts[0]['tags'] == ['browser', 'fastest']
    assert posts[0]['featured_media'] == {}
    assert posts[1]['featured_media'] == {}
    assert posts[2]['featured_media']['id'] == 75
    assert len(responses.calls) == 4