Esempio n. 1
0
def fetch_stories(refresh_clients=False):
    """
    fetch userstories from pivotaltracker and add some information
    into the database.
    """
    redis.flushdb()

    request = PivotalRequest()
    pipe = redis.pipeline(transaction=True)

    for iteration in request.iter_iterations():
        iteration_id = iteration['id']
        Iteration.create(iteration, pipe=pipe)

        app.logger.info('Processing iteration: %s', iteration_id)

        for story in request.iter_stories(iteration['stories']):
            story_id = story['id']
            Story.create(story, pipe=pipe)
            Iteration.add_story(iteration_id, story_id, pipe=pipe)

            app.logger.info(story_id)

    app.logger.info('retrieve stories in the icebox')
    for story in request.iter_icebox():
        story_id = story['id']
        Story.create(story, pipe=pipe)

        app.logger.info(story_id)

    pipe.execute()

    if refresh_clients:
        from wafwfy.events import refresh_clients as refresh_clients_fun
        refresh_clients_fun()
Esempio n. 2
0
    def test_get_all_stories(self):
        request = PivotalRequest()
        request.get = lambda dummy: open('stories').read()

        self.assertEqual(len(list(request.iter_stories())), 169)