def test_cli_2odt(self): with cli(argv=['-f', 'odt', '-o', self.out_dir, self.FIXTURE_FILE], credentials=self.credentials) as app: app.run() # check that file downloaded self.assertTrue(os.path.isfile(os.path.join(self.out_dir, 'example.odt'))) # check that file has correct content doc = opendocument.load(os.path.join(self.out_dir, 'example.odt')) root = ElementTree.fromstring(doc.toXml().encode('utf-8')) self.assertRegexpMatches(GDocDown.get_element_text(root), 'gdoc_down example file')
def test_cli_gdoc_2odt(self): with cli(argv=['-f', 'odt', '-o', self.out_dir, self.GDOC_FILE], credentials=self.credentials) as app: app.run() # check that file downloaded self.assertTrue(os.path.isfile(os.path.join(self.out_dir, 'example.odt'))) # check that file has correct content doc = opendocument.load(os.path.join(self.out_dir, 'example.odt')) root = ElementTree.fromstring(doc.toXml().encode('utf-8')) self.assertRegex(GDocDown.get_element_text(root), 'gdoc_down example file')
def test_cli_2rtf(self): with cli(argv=['-f', 'rtf', '-o', self.out_dir, self.FIXTURE_FILE], credentials=self.credentials) as app: app.run() # check that file downloaded self.assertTrue(os.path.isfile(os.path.join(self.out_dir, 'example.rtf'))) # check that file has correct content if sys.version_info < (3, 0, 0): rtf2xml.ParseRtf.ParseRtf( in_file=os.path.join(self.out_dir, 'example.rtf'), out_file=os.path.join(self.out_dir, 'example.xml'), ).parse_rtf() root = ElementTree.parse(os.path.join(self.out_dir, 'example.xml')) self.assertRegexpMatches(GDocDown.get_element_text(root.getroot()), 'gdoc_down example file')
def test_cli_gdoc_2rtf(self): with cli(argv=['-f', 'rtf', '-o', self.out_dir, self.GDOC_FILE], credentials=self.credentials) as app: app.run() # check that file downloaded self.assertTrue(os.path.isfile(os.path.join(self.out_dir, 'example.rtf'))) # check that file has correct content if sys.version_info < (3, 0, 0): rtf2xml.ParseRtf.ParseRtf( in_file=os.path.join(self.out_dir, 'example.rtf'), out_file=os.path.join(self.out_dir, 'example.xml'), ).parse_rtf() root = ElementTree.parse(os.path.join(self.out_dir, 'example.xml')) self.assertRegex(GDocDown.get_element_text(root.getroot()), 'gdoc_down example file')