def __create_changelist__(src, checksum=True): """ Create a changelist xml for the source denominated by src. :param src: 's1', 's2' etc. :param checksum: should checksums be added to the xml. :return: None """ abs_path = os.path.dirname(os.path.abspath(__name__)) data = [] path = os.path.join(abs_path, "rs/source", src, "files") for root, directories, filenames in os.walk(path): for filename in filenames: data.append(os.path.join(root, filename)) paths = ",".join(data) outfile = os.path.join(abs_path, "rs/source", src, "changelist.xml") ref_sitemap = pathlib.Path( os.path.join(abs_path, "rs/source", src, "resourcelist.xml")).as_uri() # create a changelist from the files in test/rs/source/{src}/files based on ^that client = Client(checksum=checksum) prefix = "http://localhost:8000/rs/source/" + src + "/files" resourcedir = os.path.join(abs_path, "rs/source", src, "files") args = [prefix, resourcedir] client.set_mappings(args) client.write_change_list(paths=paths, outfile=outfile, ref_sitemap=ref_sitemap)
def __create_changelist__(src, checksum=True): """ Create a changelist xml for the source denominated by src. :param src: 's1', 's2' etc. :param checksum: should checksums be added to the xml. :return: None """ abs_path = os.path.dirname(os.path.abspath(__name__)) data = [] path = os.path.join(abs_path, "rs/source", src, "files") for root, directories, filenames in os.walk(path): for filename in filenames: data.append(os.path.join(root, filename)) paths = ",".join(data) outfile = os.path.join(abs_path, "rs/source", src, "changelist.xml") ref_sitemap = pathlib.Path(os.path.join(abs_path, "rs/source", src, "resourcelist.xml")).as_uri() # create a changelist from the files in test/rs/source/{src}/files based on ^that client = Client(checksum=checksum) prefix = "http://localhost:8000/rs/source/" + src + "/files" resourcedir = os.path.join(abs_path, "rs/source", src, "files") args = [prefix, resourcedir] client.set_mappings(args) client.write_change_list(paths=paths, outfile=outfile, ref_sitemap=ref_sitemap)
def test45_write_change_list(self): c = Client() ex1 = 'tests/testdata/examples_from_spec/resourcesync_ex_1.xml' with capture_stdout() as capturer: c.write_change_list(ref_sitemap=ex1, newref_sitemap=ex1) self.assertTrue( re.search(r'<rs:md capability="changelist"', capturer.result) ) # compare ex1 with testdata on disk c.set_mappings( ['http://example.org/','tests/testdata/'] ) with capture_stdout() as capturer: c.write_change_list(ref_sitemap=ex1, paths='tests/testdata/dir1') self.assertTrue( re.search(r'<rs:md capability="changelist"', capturer.result) ) self.assertTrue( re.search(r'<url><loc>http://example.com/res1</loc><rs:md change="deleted" /></url>', capturer.result) ) # to file outfile = os.path.join(self.tmpdir,'cl_out.xml') c.write_change_list(ref_sitemap=ex1, newref_sitemap=ex1, outfile=outfile) self.assertTrue( os.path.getsize(outfile)>100 )
def test45_write_change_list(self): c = Client() ex1 = 'tests/testdata/examples_from_spec/resourcesync_ex_1.xml' with capture_stdout() as capturer: c.write_change_list(ref_sitemap=ex1, newref_sitemap=ex1) self.assertTrue( re.search(r'<rs:md capability="changelist"', capturer.result)) # compare ex1 with testdata on disk c.set_mappings(['http://example.org/', 'tests/testdata/']) with capture_stdout() as capturer: c.write_change_list(ref_sitemap=ex1, paths='tests/testdata/dir1') self.assertTrue( re.search(r'<rs:md capability="changelist"', capturer.result)) self.assertTrue( re.search( r'<url><loc>http://example.com/res1</loc><rs:md change="deleted" /></url>', capturer.result)) # to file outfile = os.path.join(self.tmpdir, 'cl_out.xml') c.write_change_list(ref_sitemap=ex1, newref_sitemap=ex1, outfile=outfile) self.assertTrue(os.path.getsize(outfile) > 100)