コード例 #1
0
ファイル: test_publishers.py プロジェクト: tomlanyon/pulp
 def test_publisher(self):
     # setup
     units = []
     for n in range(0, 3):
         fn = 'test_%d' % n
         relative_path = os.path.join(self.RELATIVE_PATH, fn)
         path = os.path.join(self.unit_dir, relative_path)
         fp = open(path, 'w')
         fp.write(fn)
         fp.close()
         unit = {
             'type_id': 'unit',
             'unit_key': {
                 'n': n
             },
             'storage_path': path,
             'relative_path': relative_path
         }
         units.append(unit)
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     p = HttpPublisher(base_url, virtual_host, repo_id)
     p.publish(units)
     # verify
     conf = DownloaderConfig()
     downloader = HTTPSCurlDownloader(conf)
     manifest_path = p.manifest_path()
     working_dir = os.path.join(self.tmpdir, 'working_dir')
     os.makedirs(working_dir)
     manifest = Manifest()
     url = 'file://' + manifest_path
     manifest.fetch(url, working_dir, downloader)
     manifest.fetch_units(url, downloader)
     units = manifest.get_units()
     n = 0
     for unit, ref in units:
         file_content = 'test_%d' % n
         _download = unit['_download']
         url = _download['url']
         self.assertEqual(
             url, '/'.join((base_url, publish_dir[1:], repo_id,
                            unit['relative_path'])))
         path = url.split('//', 1)[1]
         self.assertTrue(os.path.islink(path))
         f = open(path)
         s = f.read()
         f.close()
         self.assertEqual(s, file_content)
         self.assertEqual(unit['unit_key']['n'], n)
         n += 1
コード例 #2
0
ファイル: test_publishers.py プロジェクト: fdammeke/pulp
 def test_unstage(self):
     # setup
     units = self.populate()
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     p = HttpPublisher(base_url, virtual_host, repo_id)
     p.publish(units)
     p.unstage()
     # verify
     self.assertFalse(os.path.exists(p.tmp_dir))
コード例 #3
0
 def test_unstage(self):
     # setup
     units = self.populate()
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     p = HttpPublisher(base_url, virtual_host, repo_id)
     p.publish(units)
     p.unstage()
     # verify
     self.assertFalse(os.path.exists(p.tmp_dir))
コード例 #4
0
ファイル: test_publishers.py プロジェクト: tomlanyon/pulp
 def test_publisher(self):
     # setup
     units = []
     for n in range(0, 3):
         fn = 'test_%d' % n
         relative_path = os.path.join(self.RELATIVE_PATH, fn)
         path = os.path.join(self.unit_dir, relative_path)
         fp = open(path, 'w')
         fp.write(fn)
         fp.close()
         unit = {'type_id':'unit', 'unit_key':{'n':n}, 'storage_path':path, 'relative_path':relative_path}
         units.append(unit)
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     p = HttpPublisher(base_url, virtual_host, repo_id)
     p.publish(units)
     # verify
     conf = DownloaderConfig()
     downloader = HTTPSCurlDownloader(conf)
     manifest_path = p.manifest_path()
     working_dir = os.path.join(self.tmpdir, 'working_dir')
     os.makedirs(working_dir)
     manifest = Manifest()
     url = 'file://' + manifest_path
     manifest.fetch(url, working_dir, downloader)
     manifest.fetch_units(url, downloader)
     units = manifest.get_units()
     n = 0
     for unit, ref in units:
         file_content = 'test_%d' % n
         _download = unit['_download']
         url = _download['url']
         self.assertEqual(url, '/'.join((base_url, publish_dir[1:], repo_id, unit['relative_path'])))
         path = url.split('//', 1)[1]
         self.assertTrue(os.path.islink(path))
         f = open(path)
         s = f.read()
         f.close()
         self.assertEqual(s, file_content)
         self.assertEqual(unit['unit_key']['n'], n)
         n += 1
コード例 #5
0
ファイル: test_publishers.py プロジェクト: domcleal/pulp
 def test_publisher(self):
     # setup
     units = []
     for n in range(0, 3):
         fn = 'test_%d' % n
         path = os.path.join(self.unit_dir, fn)
         fp = open(path, 'w')
         fp.write(fn)
         fp.close()
         unit = {'type_id':'unit', 'unit_key':{'n':n}, 'storage_path':path}
         units.append(unit)
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     p = HttpPublisher(base_url, virtual_host, repo_id)
     p.publish(units)
     # verify
     conf = DownloaderConfig('http')
     downloader = factory.get_downloader(conf)
     manifest_path = p.manifest_path()
     manifest = Manifest()
     url = 'file://'+manifest_path
     units = manifest.read(url, downloader)
     n = 0
     for unit in units:
         file_content = 'test_%d' % n
         _download = unit['_download']
         url = _download['url']
         self.assertEqual(url.rsplit('/', 1)[0],'/'.join((base_url, publish_dir[1:], repo_id, 'content')))
         path = url.split('//', 1)[1]
         self.assertTrue(os.path.islink(path))
         f = open(path)
         s = f.read()
         f.close()
         self.assertEqual(s, file_content)
         self.assertEqual(unit['unit_key']['n'], n)
         n += 1