Пример #1
0
    def testStop(self):

        '''
        A GET request should stop the slicer for a haiku.
        '''

        # Create an admin and haiku.
        admin = User.createAdministrator('username', 'password')
        haiku = Haiku.createHaiku(admin.id, 'test', 1000, 1, 5, 100, 30, 1000)

        # Start the slicer
        sched.createSlicer(haiku, slicer.slice)

        with self.app as c:

            # Re-get the haiku.
            haiku = Haiku.getHaikuBySlug('test')

            # Push in a user id.
            with c.session_transaction() as s:
                s['user_id'] = admin.id

            # Hit the route, check for redirect back to browse.
            rv = c.get('/admin/stop/' + str(haiku.id), follow_redirects=True)
            self.assertTemplateUsed('admin/browse.html')

            # Check that the slicer is not present.
            job = sched.getJobByHaiku(haiku)
            self.assertFalse(job)
Пример #2
0
def start(admin, id):

    ''' Start a haiku. '''

    # Get the record, start the slicer.
    haiku = models.Haiku.query.get(id)
    sched.createSlicer(haiku, slicer.slice)

    return redirect(url_for('browse'))