Ejemplo n.º 1
0
    def test_add_unit_metadata(self):
        context = FilelistsXMLFileContext(self.working_dir, 3)
        context.metadata_file_handle = mock.Mock()

        context.add_unit_metadata(mock.Mock(repodata={'filelists': 'bar'}))

        context.metadata_file_handle.write.assert_called_once_with('bar')
Ejemplo n.º 2
0
    def test_add_unit_metadata(self):
        context = FilelistsXMLFileContext(self.working_dir, 3)
        context.metadata_file_handle = mock.Mock()

        context.add_unit_metadata(mock.Mock(metadata={"repodata": {"filelists": "bar"}}))

        context.metadata_file_handle.write.assert_called_once_with("bar")
Ejemplo n.º 3
0
    def test_add_unit_metadata(self):
        context = FilelistsXMLFileContext(self.working_dir, 3, 'sha256')
        context.metadata_file_handle = mock.Mock()

        context.add_unit_metadata(self.unit)

        context.metadata_file_handle.write.assert_called_once_with('somexml')
        self.unit.render_filelists.assert_called_once_with('sha256')
Ejemplo n.º 4
0
    def test_add_unit_metadata(self):
        context = FilelistsXMLFileContext(self.working_dir, 3, 'sha256')
        context.metadata_file_handle = mock.Mock()

        context.add_unit_metadata(self.unit)

        context.metadata_file_handle.write.assert_called_once_with('somexml')
        self.unit.render_filelists.assert_called_once_with('sha256')
    def test_filelists_file_creation(self):

        path = os.path.join(self.metadata_file_dir, REPO_DATA_DIR_NAME, FILE_LISTS_XML_FILE_NAME)

        context = FilelistsXMLFileContext(self.metadata_file_dir, 0)

        context._open_metadata_file_handle()
        context._close_metadata_file_handle()

        self.assertTrue(os.path.exists(path))
Ejemplo n.º 6
0
    def test_add_unit_metadata_unicode(self):
        """
        Test that the filelists repodata is passed as a str even if it's a unicode object.
        """
        context = FilelistsXMLFileContext(self.working_dir, 3)
        context.metadata_file_handle = mock.Mock()
        expected_call = 'some unicode'
        repodata = {'filelists': unicode(expected_call)}

        context.add_unit_metadata(mock.Mock(repodata=repodata))
        context.metadata_file_handle.write.assert_called_once_with(expected_call)
Ejemplo n.º 7
0
    def test_add_unit_metadata_unicode(self):
        """
        Test that the filelists repodata is passed as a str even if it's a unicode object.
        """
        context = FilelistsXMLFileContext(self.working_dir, 3, 'sha256')
        context.metadata_file_handle = mock.Mock()
        expected_call = u'some unicode'
        self.unit.render_filelists.return_value = expected_call

        context.add_unit_metadata(self.unit)
        context.metadata_file_handle.write.assert_called_once_with(expected_call)
        self.unit.render_filelists.assert_called_once_with('sha256')
Ejemplo n.º 8
0
    def test_add_unit_metadata_unicode(self):
        """
        Test that the filelists repodata is passed as a str even if it's a unicode object.
        """
        context = FilelistsXMLFileContext(self.working_dir, 3, 'sha256')
        context.metadata_file_handle = mock.Mock()
        expected_call = u'some unicode'
        self.unit.render_filelists.return_value = expected_call

        context.add_unit_metadata(self.unit)
        context.metadata_file_handle.write.assert_called_once_with(
            expected_call)
        self.unit.render_filelists.assert_called_once_with('sha256')
Ejemplo n.º 9
0
    def process_main(self, unit=None):
        wd = self.get_working_dir()
        total = len(self.parent.publish_msi.units +
                    self.parent.publish_msm.units)
        checksum_type = 'sha256'
        with PrimaryXMLFileContext(wd, total, checksum_type) as primary:
            units = itertools.chain(self.parent.publish_msi.units,
                                    self.parent.publish_msm.units)
            for unit in units:
                primary.add_unit_metadata(unit)
        with FilelistsXMLFileContext(wd, checksum_type) as filelists:
            for unit in units:
                filelists.add_unit_metadata(unit)
        with OtherXMLFileContext(wd, checksum_type) as other:
            for unit in units:
                other.add_unit_metadata(unit)

        with RepomdXMLFileContext(wd, checksum_type) as repomd:
            repomd.add_metadata_file_metadata('primary',
                                              primary.metadata_file_path,
                                              primary.checksum)
            repomd.add_metadata_file_metadata('filelists',
                                              filelists.metadata_file_path,
                                              filelists.checksum)
            repomd.add_metadata_file_metadata('other',
                                              other.metadata_file_path,
                                              other.checksum)
    def test_filelists_closing_tag(self):

        context = FilelistsXMLFileContext(self.metadata_file_dir, 0)
        context._open_metadata_file_handle()

        self.assertRaises(NotImplementedError, context._write_root_tag_close)

        context._write_root_tag_open()

        try:
            context._write_root_tag_close()

        except Exception, e:
            self.fail(e.message)
    def test_filelists_unit_metadata(self):

        path = os.path.join(self.metadata_file_dir, REPO_DATA_DIR_NAME, FILE_LISTS_XML_FILE_NAME)

        unit = self._generate_rpm("ive-got-files")

        context = FilelistsXMLFileContext(self.metadata_file_dir, 1)

        context._open_metadata_file_handle()
        context.add_unit_metadata(unit)
        context._close_metadata_file_handle()

        handle = gzip.open(path, "r")
        content = handle.read()
        handle.close()

        self.assertEqual(content, "FILELISTS")
    def test_filelists_opening_tag(self):

        path = os.path.join(self.metadata_file_dir, REPO_DATA_DIR_NAME, FILE_LISTS_XML_FILE_NAME)

        context = FilelistsXMLFileContext(self.metadata_file_dir, 0)

        context._open_metadata_file_handle()
        context._write_root_tag_open()
        context._close_metadata_file_handle()

        self.assertNotEqual(os.path.getsize(path), 0)

        filelists_handle = gzip.open(path, "r")
        content = filelists_handle.read()
        filelists_handle.close()

        self.assertTrue(content.startswith("<filelists"))
        self.assertEqual(content.count('xmlns="%s"' % FILE_LISTS_NAMESPACE), 1)
        self.assertEqual(content.count('packages="0"'), 1)
Ejemplo n.º 13
0
 def test_init(self):
     context = FilelistsXMLFileContext(self.working_dir, 3)
     self.assertEquals(context.fast_forward, False)
     self.assertEquals(context.num_packages, 3)