diff options
| author | Scott Bahling <sbahling@suse.com> | 2020-02-06 22:16:02 +0100 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.com> | 2020-02-06 22:35:43 +0100 |
| commit | cd12f43cd2c98826bb0ea092ef590a91e5842886 (patch) | |
| tree | fc13c2f90a9e3190ab172b1556dc1eb3caa124b4 /test/test_fileinfo.py | |
| parent | c86fdd52a30ca1833149d46b7fee9135a74e4598 (diff) | |
| download | obsapi-cd12f43cd2c98826bb0ea092ef590a91e5842886.tar.gz obsapi-cd12f43cd2c98826bb0ea092ef590a91e5842886.tar.xz obsapi-cd12f43cd2c98826bb0ea092ef590a91e5842886.zip | |
Handle passing bytes to the FileInfo class
Move class to own file and enhance tests
Diffstat (limited to 'test/test_fileinfo.py')
| -rw-r--r-- | test/test_fileinfo.py | 26 |
1 files changed, 26 insertions, 0 deletions
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')) |
