Esempio n. 1
0
    def test_remove_does_not_affect_others(self):
        from pdfserver.models import Upload
        assert Upload.query.count() == 0

        rv = self.app.get('/')
        self.assertEquals(rv.status_code, 200)

        rv = self.app.post('/handleform',
                           data={'file': (self.get_pdf_stream(), 'test.pdf')},
                           follow_redirects=True)

        # Get file id first upload
        ids = self.extract_ids_from_main_page(rv.data)
        self.assert_(len(ids) == 1)

        rv = self.app.post('/handleform',
                           data={'file': (self.get_pdf_stream(), 'test2.pdf')},
                           follow_redirects=True)
        # Get file id second upload
        ids2 = self.extract_ids_from_main_page(rv.data)
        ids2.remove(ids[0])
        self.assert_(len(ids2) == 1)

        self.assertEquals(Upload.query.count(), 2)

        # Delete first file
        rv = self.app.post('/delete',
                           data={
                               'delete': 'delete',
                               'id': ids[0]
                           },
                           follow_redirects=True)

        self.assertEquals(rv.status_code, 200)

        # Make sure second file still exists
        self.assertEquals(Upload.query.count(), 1)
        self.assert_(Upload.get_for_id(ids2[0]) is not None)

        self.clean_up()
Esempio n. 2
0
    def test_remove_does_not_affect_others(self):
        from pdfserver.models import Upload
        assert Upload.query.count() == 0

        rv = self.app.get('/')
        self.assertEquals(rv.status_code, 200)

        rv = self.app.post('/handleform',
                           data={'file': (self.get_pdf_stream(), 'test.pdf')},
                           follow_redirects=True)

        # Get file id first upload
        ids = self.extract_ids_from_main_page(rv.data)
        self.assert_(len(ids) == 1)

        rv = self.app.post('/handleform',
                           data={'file': (self.get_pdf_stream(), 'test2.pdf')},
                           follow_redirects=True)
        # Get file id second upload
        ids2 = self.extract_ids_from_main_page(rv.data)
        ids2.remove(ids[0])
        self.assert_(len(ids2) == 1)

        self.assertEquals(Upload.query.count(), 2)

        # Delete first file
        rv = self.app.post('/delete',
                           data={'delete': 'delete', 'id': ids[0]},
                           follow_redirects=True)

        self.assertEquals(rv.status_code, 200)

        # Make sure second file still exists
        self.assertEquals(Upload.query.count(), 1)
        self.assert_(Upload.get_for_id(ids2[0]) is not None)

        self.clean_up()
Esempio n. 3
0
 def clean_up(self):
     from pdfserver.models import Upload
     for upload in Upload.query.all():
         Upload.delete(upload)
     Upload.commit()
Esempio n. 4
0
 def clean_up(self):
     from pdfserver.models import Upload
     for upload in Upload.query.all():
         Upload.delete(upload)
     Upload.commit()