1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add rpm_qi tests

This commit is contained in:
Kelly Brazil
2021-04-06 18:34:08 -07:00
parent abee226591
commit 14b727cc71
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1 @@
[{"name":"make","epoch":1,"version":"3.82","release":"24.el7","architecture":"x86_64","install_date":"Wed 16 Oct 2019 09:21:42 AM PDT","group":"Development/Tools","size":1160660,"license":"GPLv2+","signature":"RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5","source_rpm":"make-3.82-24.el7.src.rpm","build_date":"Thu 08 Aug 2019 05:47:25 PM PDT","build_host":"x86-01.bsys.centos.org","relocations":"(not relocatable)","packager":"CentOS BuildSystem <http://bugs.centos.org>","vendor":"CentOS","url":"http://www.gnu.org/software/make/","summary":"A GNU tool which simplifies the build process for users","description":"A GNU tool for controlling the generation of executables and other non-source files of a program from the program's source files. Make allows users to build and install packages without any significant knowledge about the details of the build process. The details about how the program should be built are provided for make in the program's makefile.","build_epoch":1565311645,"build_epoch_utc":null}]

View File

@ -0,0 +1,26 @@
Name : make
Epoch : 1
Version : 3.82
Release : 24.el7
Architecture: x86_64
Install Date: Wed 16 Oct 2019 09:21:42 AM PDT
Group : Development/Tools
Size : 1160660
License : GPLv2+
Signature : RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5
Source RPM : make-3.82-24.el7.src.rpm
Build Date : Thu 08 Aug 2019 05:47:25 PM PDT
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.gnu.org/software/make/
Summary : A GNU tool which simplifies the build process for users
Description :
A GNU tool for controlling the generation of executables and other
non-source files of a program from the program's source files. Make
allows users to build and install packages without any significant
knowledge about the details of the build process. The details about
how the program should be built are provided for make in the program's
makefile.

46
tests/test_rpm_qai.py Normal file
View File

@ -0,0 +1,46 @@
import os
import unittest
import json
import jc.parsers.rpm_qi
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
def setUp(self):
# input
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/rpm-qai.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_rpm_qai = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/rpm-qi-package.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_rpm_qi_package = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/rpm-qai.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_rpm_qai_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/rpm-qi-package.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_rpm_qi_package_json = json.loads(f.read())
def test_rpm_qi_nodata(self):
"""
Test 'rpm -qi' with no data
"""
self.assertEqual(jc.parsers.rpm_qi.parse('', quiet=True), [])
def test_rpm_qai_centos_7_7(self):
"""
Test 'rpm -qai' on Centos 7.7
"""
self.assertEqual(jc.parsers.rpm_qi.parse(self.centos_7_7_rpm_qai, quiet=True), self.centos_7_7_rpm_qai_json)
def test_rpm_qi_package_centos_7_7(self):
"""
Test 'rpm -qi make' on Centos 7.7
"""
self.assertEqual(jc.parsers.rpm_qi.parse(self.centos_7_7_rpm_qi_package, quiet=True), self.centos_7_7_rpm_qi_package_json)
if __name__ == '__main__':
unittest.main()