From cd12f43cd2c98826bb0ea092ef590a91e5842886 Mon Sep 17 00:00:00 2001 From: Scott Bahling Date: Thu, 6 Feb 2020 22:16:02 +0100 Subject: Handle passing bytes to the FileInfo class Move class to own file and enhance tests --- test/test_fileinfo.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/test_fileinfo.py (limited to 'test/test_fileinfo.py') diff --git a/test/test_fileinfo.py b/test/test_fileinfo.py new file mode 100644 index 0000000..18d1f15 --- /dev/null +++ b/test/test_fileinfo.py @@ -0,0 +1,26 @@ +import os +import pytest +from lxml import etree +from obsapi import FileInfo +from . import test_dir + + +with open(os.path.join(test_dir, 'binary_fileinfo.xml'), 'rb') as f: + xml_as_bytes = f.read() + + +with open(os.path.join(test_dir, 'binary_fileinfo.xml'), 'r') as f: + xml_as_str = f.read() + + +@pytest.mark.parametrize('xml', (xml_as_bytes, xml_as_str)) +def test_fileinfo(xml): + finfo = FileInfo(xml) + root = etree.fromstring(xml) + assert finfo.name == root.find('name').text + assert finfo.version == root.find('version').text + assert finfo.release == root.find('release').text + assert finfo.arch == root.find('arch').text + assert finfo.summary == root.find('summary').text + assert finfo.description == root.find('description').text + assert len(finfo.requires) == len(root.findall('requires')) -- cgit v1.2.3