Пример #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')
Пример #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")
Пример #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')
Пример #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')
Пример #5
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)
Пример #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, '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')
Пример #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')
    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")