def test_file_delete_it(self):
        realpath = os.path.join(GLSetting.static_path, self.fakeFile['filename'])
        dumped_file = yield admstaticfiles.dump_static_file(self.fakeFile, realpath)
        self.assertTrue(dumped_file.has_key('filelocation'))

        self.responses = []

        handler = self.request(role='admin', kwargs={'path': GLSetting.static_path})
        yield handler.delete(self.fakeFile['filename'])
Esempio n. 2
0
    def test_file_delete_it(self):
        realpath = os.path.join(GLSetting.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield admstaticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue(dumped_file.has_key('filelocation'))

        self.responses = []

        handler = self.request(role='admin',
                               kwargs={'path': GLSetting.static_path})
        yield handler.delete(self.fakeFile['filename'])
Esempio n. 3
0
    def test_get(self):

        fakeFile = dict()
        fakeFile['body'] = StringIO()
        fakeFile['body'].write(TestAdminStaticFile.crappyjunk)
        fakeFile['body_len'] = len(TestAdminStaticFile.crappyjunk)
        fakeFile['content_type'] = 'image/jpeg'
        fakeFile['filename'] = 'imag0005.jpg'

        realpath = os.path.join(GLSetting.static_path, "ouffff")
        dumped_file = yield admstaticfiles.dump_static_file(fakeFile, realpath)
        self.assertTrue(dumped_file.has_key('filelocation'))

        handler = self.request(role='admin')
        yield handler.get()
        self.assertTrue( isinstance(self.responses[0], list) )
    def test_get_list_with_one_custom_file(self):
        realpath = os.path.join(GLSetting.static_path, self.fakeFile['filename'])
        dumped_file = yield admstaticfiles.dump_static_file(self.fakeFile, realpath)
        self.assertTrue(dumped_file.has_key('filelocation'))

        handler = self.request(role='admin')
        yield handler.get()
        self.assertTrue( isinstance(self.responses[0], list) )

        found = False

        for f in self.responses[0]:
            if f['filename'] == self.fakeFile['filename']:
                found = True
                self.assertEqual(self.fakeFile['body_len'], f['size'])

        self.assertTrue(found)
Esempio n. 5
0
    def test_get_list_with_one_custom_file(self):
        realpath = os.path.join(GLSetting.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield admstaticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue(dumped_file.has_key('filelocation'))

        handler = self.request(role='admin')
        yield handler.get()
        self.assertTrue(isinstance(self.responses[0], list))

        found = False

        for f in self.responses[0]:
            if f['filename'] == self.fakeFile['filename']:
                found = True
                self.assertEqual(self.fakeFile['body_len'], f['size'])

        self.assertTrue(found)