Example #1
0
 def test_write_repo(self):
     """Verify the content of a repo file"""
     cfg = {
         'repos': [
             {
                 'baseurl': 'http://foo',
                 'name': 'test-foo',
                 'id': 'testing-foo'
             },
         ]
     }
     root_d = self.tmp_dir()
     cc_zypper_add_repo._write_repos(cfg['repos'], root_d)
     contents = util.load_file("%s/testing-foo.repo" % root_d)
     parser = configparser.ConfigParser()
     parser.read_string(contents)
     expected = {
         'testing-foo': {
             'name': 'test-foo',
             'baseurl': 'http://foo',
             'enabled': '1',
             'autorefresh': '1'
         }
     }
     for section in expected:
         self.assertTrue(parser.has_section(section),
                         "Contains section {0}".format(section))
         for k, v in expected[section].items():
             self.assertEqual(parser.get(section, k), v)
 def test_write_repo(self):
     """Verify the content of a repo file"""
     cfg = {
         'repos': [
             {
                 'baseurl': 'http://foo',
                 'name': 'test-foo',
                 'id': 'testing-foo'
             },
         ]
     }
     root_d = self.tmp_dir()
     cc_zypper_add_repo._write_repos(cfg['repos'], root_d)
     contents = util.load_file("%s/testing-foo.repo" % root_d)
     parser = self.parse_and_read(StringIO(contents))
     expected = {
         'testing-foo': {
             'name': 'test-foo',
             'baseurl': 'http://foo',
             'enabled': '1',
             'autorefresh': '1'
         }
     }
     for section in expected:
         self.assertTrue(parser.has_section(section),
                         "Contains section {0}".format(section))
         for k, v in expected[section].items():
             self.assertEqual(parser.get(section, k), v)
Example #3
0
 def test_no_repo_data(self):
     """When there is no repo data nothing should happen"""
     root_d = self.tmp_dir()
     self.reRoot(root_d)
     cc_zypper_add_repo._write_repos(None, root_d)
     content = glob.glob('%s/*' % root_d)
     self.assertEqual(len(content), 0)
 def test_no_repo_data(self):
     """When there is no repo data nothing should happen"""
     root_d = self.tmp_dir()
     self.reRoot(root_d)
     cc_zypper_add_repo._write_repos(None, root_d)
     content = glob.glob('%s/*' % root_d)
     self.assertEqual(len(content), 0)
Example #5
0
 def test_write_repo(self):
     """Verify the content of a repo file"""
     cfg = {
         "repos": [
             {
                 "baseurl": "http://foo",
                 "name": "test-foo",
                 "id": "testing-foo",
             },
         ]
     }
     root_d = self.tmp_dir()
     cc_zypper_add_repo._write_repos(cfg["repos"], root_d)
     contents = util.load_file("%s/testing-foo.repo" % root_d)
     parser = configparser.ConfigParser()
     parser.read_string(contents)
     expected = {
         "testing-foo": {
             "name": "test-foo",
             "baseurl": "http://foo",
             "enabled": "1",
             "autorefresh": "1",
         }
     }
     for section in expected:
         self.assertTrue(
             parser.has_section(section),
             "Contains section {0}".format(section),
         )
         for k, v in expected[section].items():
             self.assertEqual(parser.get(section, k), v)
Example #6
0
 def test_write_repos(self):
     """Verify valid repos get written"""
     cfg = self._get_base_config_repos()
     root_d = self.tmp_dir()
     cc_zypper_add_repo._write_repos(cfg['zypper']['repos'], root_d)
     repos = glob.glob('%s/*.repo' % root_d)
     expected_repos = ['testing-foo.repo', 'testing-bar.repo']
     if len(repos) != 2:
         assert 'Number of repos written is "%d" expected 2' % len(repos)
     for repo in repos:
         repo_name = os.path.basename(repo)
         if repo_name not in expected_repos:
             assert 'Found repo with name "%s"; unexpected' % repo_name
 def test_write_repos(self):
     """Verify valid repos get written"""
     cfg = self._get_base_config_repos()
     root_d = self.tmp_dir()
     cc_zypper_add_repo._write_repos(cfg['zypper']['repos'], root_d)
     repos = glob.glob('%s/*.repo' % root_d)
     expected_repos = ['testing-foo.repo', 'testing-bar.repo']
     if len(repos) != 2:
         assert 'Number of repos written is "%d" expected 2' % len(repos)
     for repo in repos:
         repo_name = os.path.basename(repo)
         if repo_name not in expected_repos:
             assert 'Found repo with name "%s"; unexpected' % repo_name
Example #8
0
 def test_bad_repo_config(self):
     """Config has no baseurl, no file should be written"""
     cfg = {
         'repos': [
             {
                 'id': 'foo',
                 'name': 'suse-test',
                 'enabled': '1'
             },
         ]
     }
     self.patchUtils(self.tmp)
     cc_zypper_add_repo._write_repos(cfg['repos'], '/etc/zypp/repos.d')
     self.assertRaises(IOError, util.load_file,
                       "/etc/zypp/repos.d/foo.repo")
 def test_bad_repo_config(self):
     """Config has no baseurl, no file should be written"""
     cfg = {
         'repos': [
             {
                 'id': 'foo',
                 'name': 'suse-test',
                 'enabled': '1'
             },
         ]
     }
     self.patchUtils(self.tmp)
     cc_zypper_add_repo._write_repos(cfg['repos'], '/etc/zypp/repos.d')
     self.assertRaises(IOError, util.load_file,
                       "/etc/zypp/repos.d/foo.repo")
Example #10
0
 def test_bad_repo_config(self):
     """Config has no baseurl, no file should be written"""
     cfg = {
         "repos": [
             {
                 "id": "foo",
                 "name": "suse-test",
                 "enabled": "1"
             },
         ]
     }
     self.patchUtils(self.tmp)
     cc_zypper_add_repo._write_repos(cfg["repos"], "/etc/zypp/repos.d")
     self.assertRaises(IOError, util.load_file,
                       "/etc/zypp/repos.d/foo.repo")