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'])
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'])
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'])
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'])
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)
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)
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)
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)
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)