def test_serve_file(self): with patch.dict(roots.__opts__, {'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'file_buffer_size': 262144}): load = {'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'loc': 0 } fnd = {'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile'} ret = roots.serve_file(load, fnd) self.assertDictEqual( ret, {'data': 'Scene 24\n\n \n OLD MAN: Ah, hee he he ha!\n ' 'ARTHUR: And this enchanter of whom you speak, he ' 'has seen the grail?\n OLD MAN: Ha ha he he he ' 'he!\n ARTHUR: Where does he live? Old man, where ' 'does he live?\n OLD MAN: He knows of a cave, a ' 'cave which no man has entered.\n ARTHUR: And the ' 'Grail... The Grail is there?\n OLD MAN: Very much ' 'danger, for beyond the cave lies the Gorge\n ' 'of Eternal Peril, which no man has ever crossed.\n ' 'ARTHUR: But the Grail! Where is the Grail!?\n ' 'OLD MAN: Seek you the Bridge of Death.\n ARTHUR: ' 'The Bridge of Death, which leads to the Grail?\n ' 'OLD MAN: Hee hee ha ha!\n\n', 'dest': 'testfile'})
def test_serve_file(self): with patch.dict(roots.__opts__, {'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'file_buffer_size': 262144}): load = {'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'loc': 0 } fnd = {'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile'} ret = roots.serve_file(load, fnd) self.assertDictEqual( ret, {'data': 'Scene 24\n\n \n OLD MAN: Ah, hee he he ha!\n ' 'ARTHUR: And this enchanter of whom you speak, he ' 'has seen the grail?\n OLD MAN: Ha ha he he he ' 'he!\n ARTHUR: Where does he live? Old man, where ' 'does he live?\n OLD MAN: He knows of a cave, a ' 'cave which no man has entered.\n ARTHUR: And the ' 'Grail... The Grail is there?\n OLD MAN: Very much ' 'danger, for beyond the cave lies the Gorge\n ' 'of Eternal Peril, which no man has ever crossed.\n ' 'ARTHUR: But the Grail! Where is the Grail!?\n ' 'OLD MAN: Seek you the Bridge of Death.\n ARTHUR: ' 'The Bridge of Death, which leads to the Grail?\n ' 'OLD MAN: Hee hee ha ha!\n\n', 'dest': 'testfile'})
def test_serve_file(self): with patch.dict( roots.__opts__, { "file_roots": self.master_opts["file_roots"], "fileserver_ignoresymlinks": False, "fileserver_followsymlinks": False, "file_ignore_regex": False, "file_ignore_glob": False, "file_buffer_size": 262144, }, ): load = {"saltenv": "base", "path": os.path.join(integration.FILES, "file", "base", "testfile"), "loc": 0} fnd = {"path": os.path.join(integration.FILES, "file", "base", "testfile"), "rel": "testfile"} ret = roots.serve_file(load, fnd) self.assertDictEqual( ret, { "data": "Scene 24\n\n \n OLD MAN: Ah, hee he he ha!\n " "ARTHUR: And this enchanter of whom you speak, he " "has seen the grail?\n OLD MAN: Ha ha he he he " "he!\n ARTHUR: Where does he live? Old man, where " "does he live?\n OLD MAN: He knows of a cave, a " "cave which no man has entered.\n ARTHUR: And the " "Grail... The Grail is there?\n OLD MAN: Very much " "danger, for beyond the cave lies the Gorge\n " "of Eternal Peril, which no man has ever crossed.\n " "ARTHUR: But the Grail! Where is the Grail!?\n " "OLD MAN: Seek you the Bridge of Death.\n ARTHUR: " "The Bridge of Death, which leads to the Grail?\n " "OLD MAN: Hee hee ha ha!\n\n", "dest": "testfile", }, )
def test_serve_file(self): with patch.dict(roots.__opts__, {"file_buffer_size": 262144}): load = { "saltenv": "base", "path": os.path.join(self.tmp_dir, "testfile"), "loc": 0, } fnd = {"path": os.path.join(self.tmp_dir, "testfile"), "rel": "testfile"} ret = roots.serve_file(load, fnd) with salt.utils.files.fopen( os.path.join(RUNTIME_VARS.BASE_FILES, 'testfile'), 'rb') as fp_: data = fp_.read() self.assertDictEqual(ret, {"data": data, "dest": "testfile"})
def test_serve_file(self): with patch.dict(roots.__opts__, {'file_buffer_size': 262144}): load = { 'saltenv': 'base', 'path': os.path.join(self.tmp_dir, 'testfile'), 'loc': 0 } fnd = { 'path': os.path.join(self.tmp_dir, 'testfile'), 'rel': 'testfile' } ret = roots.serve_file(load, fnd) with salt.utils.files.fopen(os.path.join(BASE_FILES, 'testfile'), 'rb') as fp_: data = fp_.read() self.assertDictEqual(ret, {'data': data, 'dest': 'testfile'})
def test_serve_file(self): with patch.dict(roots.__opts__, {'file_buffer_size': 262144}): load = { 'saltenv': 'base', 'path': os.path.join(FILES, 'file', 'base', 'testfile'), 'loc': 0 } fnd = { 'path': os.path.join(FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.serve_file(load, fnd) data = 'Scene 24\n\n \n OLD MAN: Ah, hee he he ha!\n ' \ 'ARTHUR: And this enchanter of whom you speak, he ' \ 'has seen the grail?\n OLD MAN: Ha ha he he he ' \ 'he!\n ARTHUR: Where does he live? Old man, where ' \ 'does he live?\n OLD MAN: He knows of a cave, a ' \ 'cave which no man has entered.\n ARTHUR: And the ' \ 'Grail... The Grail is there?\n OLD MAN: Very much ' \ 'danger, for beyond the cave lies the Gorge\n ' \ 'of Eternal Peril, which no man has ever crossed.\n ' \ 'ARTHUR: But the Grail! Where is the Grail!?\n ' \ 'OLD MAN: Seek you the Bridge of Death.\n ARTHUR: ' \ 'The Bridge of Death, which leads to the Grail?\n ' \ 'OLD MAN: Hee hee ha ha!\n\n' if salt.utils.is_windows(): data = 'Scene 24\r\n\r\n \r\n OLD MAN: Ah, hee he he ' \ 'ha!\r\n ARTHUR: And this enchanter of whom you ' \ 'speak, he has seen the grail?\r\n OLD MAN: Ha ha ' \ 'he he he he!\r\n ARTHUR: Where does he live? Old ' \ 'man, where does he live?\r\n OLD MAN: He knows of ' \ 'a cave, a cave which no man has entered.\r\n ' \ 'ARTHUR: And the Grail... The Grail is there?\r\n ' \ 'OLD MAN: Very much danger, for beyond the cave lies ' \ 'the Gorge\r\n of Eternal Peril, which no man ' \ 'has ever crossed.\r\n ARTHUR: But the Grail! ' \ 'Where is the Grail!?\r\n OLD MAN: Seek you the ' \ 'Bridge of Death.\r\n ARTHUR: The Bridge of Death, ' \ 'which leads to the Grail?\r\n OLD MAN: Hee hee ha ' \ 'ha!\r\n\r\n' self.assertDictEqual(ret, {'data': data, 'dest': 'testfile'})