Ejemplo n.º 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'])
Ejemplo n.º 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'])
Ejemplo n.º 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'])
Ejemplo n.º 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'])
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)