示例#1
0
    def test_delete_on_existent_file(self):
        self.fakeFile = self.get_dummy_file()
        realpath = os.path.join(GLSettings.static_path, self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        handler = self.request({}, role='admin')
        yield handler.delete(self.fakeFile['filename'])
示例#2
0
    def test_file_delete_it(self):
        realpath = os.path.join(GLSettings.static_path, self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        self.responses = []

        handler = self.request(role='admin')
        yield handler.delete(self.fakeFile['filename'])
示例#3
0
    def test_delete_on_existent_file(self):
        self.fakeFile = self.get_dummy_file()
        realpath = os.path.join(GLSettings.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        handler = self.request({}, role='admin')
        yield handler.delete(self.fakeFile['filename'])
示例#4
0
    def test_file_delete_it(self):
        realpath = os.path.join(GLSettings.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        self.responses = []

        handler = self.request(role='admin')
        yield handler.delete(self.fakeFile['filename'])
示例#5
0
    def test_file_download(self):
        realpath = os.path.join(GLSetting.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        self.responses = []

        handler = self.request(role='admin',
                               kwargs={'path': GLSetting.static_path})
        yield handler.get(self.fakeFile['filename'])
        self.assertEqual(self.responses[0], self.crappyjunk)
示例#6
0
    def test_get_list_with_one_custom_file(self):
        realpath = os.path.join(GLSettings.static_path, self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        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)
示例#7
0
    def test_get_list_of_files(self):
        self.fakeFile = self.get_dummy_file()
        realpath = os.path.join(GLSettings.static_path, self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        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
                break

        self.assertTrue(found)
示例#8
0
    def test_get_list_with_one_custom_file(self):
        realpath = os.path.join(GLSetting.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        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)
示例#9
0
    def test_get_list_of_files(self):
        self.fakeFile = self.get_dummy_file()
        realpath = os.path.join(GLSettings.static_path,
                                self.fakeFile['filename'])
        dumped_file = yield staticfiles.dump_static_file(
            self.fakeFile, realpath)
        self.assertTrue('filelocation' in dumped_file)

        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
                break

        self.assertTrue(found)