def test_other_file_creation(self):

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

        context = OtherXMLFileContext(self.metadata_file_dir, 0)

        context._open_metadata_file_handle()
        context._close_metadata_file_handle()

        self.assertTrue(os.path.exists(path))
    def test_other_unit_metadata(self):

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

        unit = self._generate_rpm("uh-huh")

        context = OtherXMLFileContext(self.metadata_file_dir, 1)

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

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

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

        self.assertEqual(content, "OTHER")
    def test_other_opening_tag(self):

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

        context = OtherXMLFileContext(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)

        other_handle = gzip.open(path, "r")
        context = other_handle.read()
        other_handle.close()

        self.assertTrue(context.startswith("<otherdata"))
        self.assertEqual(context.count('xmlns="%s"' % OTHER_NAMESPACE), 1)
        self.assertEqual(context.count('packages="0"'), 1)