Pass tests

This commit is contained in:
Dimitris Zlatanidis 2024-03-21 18:33:33 +02:00
parent 3699ed93aa
commit 8ff5191990
6 changed files with 48 additions and 41 deletions

View file

@ -1,12 +1,13 @@
import unittest
from slpkg.binaries.queries import BinQueries
from slpkg.load_data import LoadData
class TestBinQueries(unittest.TestCase):
def setUp(self):
self.bin_queries = BinQueries('slack')
self.repo_data = self.bin_queries.repository_data()
load = LoadData()
self.repo_data = load.load('slack')
def test_repository_data(self):
self.assertGreater(len(list(self.repo_data.keys())), 1)
@ -33,7 +34,7 @@ class TestBinQueries(unittest.TestCase):
self.assertEqual('90', self.repo_data['aaa_base']['size_uncomp'])
def test_required(self):
self.assertEqual('', self.repo_data['aaa_base']['requires'])
self.assertEqual([], self.repo_data['aaa_base']['requires'])
def test_conflicts(self):
self.assertEqual('', self.repo_data['aaa_base']['conflicts'])

View file

@ -1,22 +1,19 @@
import unittest
from slpkg.checks import Check
from slpkg.sbos.queries import SBoQueries
from slpkg.load_data import LoadData
class TestPkgInstalled(unittest.TestCase):
def setUp(self):
self.bin_queries = SBoQueries('sbo')
self.data = self.bin_queries.repository_data()
load = LoadData()
self.data = load.load('sbo')
self.check = Check('sbo')
self.packages = ['colored', 'sbo-create', 'sun']
def test_check_exists(self):
self.assertIsNone(self.check.package_exists_in_the_database(self.packages, self.data))
def test_check_unsupported(self):
self.assertIsNone(self.check.is_package_unsupported(self.packages, self.data))
def test_check_is_installed(self):
self.assertIsNone(self.check.is_package_installed(self.packages))

View file

@ -13,31 +13,45 @@ class TestConfigs(unittest.TestCase):
self.assertEqual('x86_64', self.configs.os_arch)
self.assertEqual(Path('/tmp'), self.configs.tmp_path)
self.assertEqual(Path('/tmp/slpkg'), self.configs.tmp_slpkg)
self.assertEqual(Path('/tmp/slpkg/build'), self.configs.build_path)
self.assertEqual(Path('/tmp/slpkg/'), self.configs.download_only_path)
self.assertEqual(Path('/var', 'lib', 'slpkg'), self.configs.lib_path)
self.assertEqual(Path('/etc', 'slpkg'), self.configs.etc_path)
self.assertEqual(Path('/var/lib/', 'slpkg', 'database'), self.configs.db_path)
self.assertEqual(Path('/var', 'log', 'packages'), self.configs.log_packages)
self.assertEqual(Path('/var/log/slpkg/'), self.configs.slpkg_log_path)
self.assertEqual(Path('/var/log/slpkg/deps.log'), self.configs.deps_log_file)
self.assertEqual(Path('/var/log/slpkg/'), self.configs.slpkg_log_path)
self.assertEqual('database.slpkg', self.configs.database_name)
self.assertEqual('.pkgs', self.configs.file_list_suffix)
self.assertEqual('upgradepkg --install-new', self.configs.installpkg)
self.assertEqual('upgradepkg --reinstall', self.configs.reinstall)
self.assertEqual('removepkg', self.configs.removepkg)
self.assertEqual(True, self.configs.colors)
self.assertEqual('-j4', self.configs.makeflags)
self.assertEqual(False, self.configs.gpg_verification)
self.assertEqual(True, self.configs.checksum_md5)
self.assertEqual(True, self.configs.dialog)
self.assertEqual('wget', self.configs.downloader)
self.assertEqual('-c -q --progress=bar:force:noscroll --show-progress', self.configs.wget_options)
self.assertEqual('', self.configs.curl_options)
self.assertEqual('-c get -e', self.configs.lftp_get_options)
self.assertEqual('-c mirror --parallel=100 --only-newer', self.configs.lftp_mirror_options)
self.assertEqual(True, self.configs.silent_mode)
self.assertEqual('-c mirror --parallel=100 --only-newer --delete', self.configs.lftp_mirror_options)
self.assertEqual(False, self.configs.silent_mode)
self.assertEqual(True, self.configs.ascii_characters)
self.assertEqual(True, self.configs.ask_question)
self.assertEqual(False, self.configs.parallel_downloads)
self.assertEqual('*', self.configs.file_pattern)
self.assertEqual(True, self.configs.spinning_bar)
self.assertEqual('pixel', self.configs.progress_spinner)
self.assertEqual('green', self.configs.spinner_color)
self.assertEqual('bold_green', self.configs.border_color)
self.assertEqual(True, self.configs.case_sensitive)
self.assertEqual(True, self.configs.process_log)
self.assertEqual(False, self.configs.urllib_retries)
self.assertEqual(False, self.configs.urllib_redirect)
self.assertEqual(3.0, self.configs.urllib_timeout)
self.assertEqual('', self.configs.proxy_address)
self.assertEqual('', self.configs.proxy_username)
self.assertEqual('', self.configs.proxy_password)

View file

@ -1,12 +1,12 @@
import unittest
from slpkg.sbos.queries import SBoQueries
from slpkg.load_data import LoadData
class TestSBoQueries(unittest.TestCase):
def setUp(self):
self.sbo_queries = SBoQueries('sbo')
self.data: dict = self.sbo_queries.repository_data()
load = LoadData()
self.data: dict = load.load('sbo')
self.name: str = 'slpkg'
def test_slackbuild(self):
@ -17,26 +17,26 @@ class TestSBoQueries(unittest.TestCase):
def test_sources_x86(self):
self.assertEqual(['https://gitlab.com/dslackw/slpkg/-/archive'
'/4.8.2/slpkg-4.8.2.tar.gz'], self.data[self.name]['download'].split())
'/4.9.8/slpkg-4.9.8.tar.gz'], self.data[self.name]['download'])
def test_sources_x86_64(self):
self.assertEqual([], self.data[self.name]['download64'].split())
self.assertEqual([], self.data[self.name]['download64'])
def test_requires(self):
self.assertEqual(['SQLAlchemy', 'python3-pythondialog', 'python3-progress'],
self.data[self.name]['requires'].split())
self.assertEqual(['python3-build', 'SQLAlchemy', 'python3-pythondialog', 'python3-progress'],
self.data[self.name]['requires'])
def test_version(self):
self.assertEqual('4.8.2', self.data[self.name]['version'])
self.assertEqual('4.9.8', self.data[self.name]['version'])
def test_checksum_x86(self):
self.assertListEqual(['96197dd92a2cc70e163eacdf83909252'], self.data[self.name]['md5sum'].split())
self.assertListEqual(['9f9cf626d7246202886774c6cbc2cccf'], self.data[self.name]['md5sum'])
def test_checksum_x86_64(self):
self.assertListEqual([], self.data[self.name]['md5sum64'].split())
self.assertListEqual([], self.data[self.name]['md5sum64'])
def test_files(self):
self.assertEqual(5, len(self.data[self.name]['files'].split()))
self.assertEqual(5, len(self.data[self.name]['files']))
def test_description(self):
self.assertEqual('slpkg (Slackware Packaging Tool)', self.data[self.name]['description'])

View file

@ -2,16 +2,14 @@ import unittest
from slpkg.upgrade import Upgrade
from slpkg.utilities import Utilities
from slpkg.sbos.queries import SBoQueries
from slpkg.binaries.queries import BinQueries
from slpkg.load_data import LoadData
class TestUtilities(unittest.TestCase):
def setUp(self):
self.load = LoadData()
self.utils = Utilities()
self.sbo_queries = SBoQueries('sbo')
self.data: dict = self.sbo_queries.repository_data()
self.data: dict = self.load.load('sbo')
def test_installed_is_upgradable_for_sbo_repository(self):
packages: list = ['sbo-create', 'ptpython', 'pycharm', 'powerline-status']
@ -20,16 +18,14 @@ class TestUtilities(unittest.TestCase):
def test_installed_is_upgradable_for_slack_patches_repository(self):
repo: str = 'slack_patches'
bin_queries = BinQueries(repo)
data: dict = bin_queries.repository_data()
data: dict = self.load.load(repo)
packages: list = ['vim', 'httpd', 'seamonkey', 'sudo', 'python3', 'qt5', 'php']
for pkg in packages:
self.assertFalse(False, Upgrade('slack', data).is_package_upgradeable(pkg))
def test_installed_is_upgradable_for_alien_repository(self):
repo: str = 'alien'
bin_queries = BinQueries(repo)
data: dict = bin_queries.repository_data()
data: dict = self.load.load(repo)
packages: list = ['audacity', 'vlc', 'dnspython']
for pkg in packages:
self.assertFalse(False, Upgrade('alien', data).is_package_upgradeable(pkg))

View file

@ -1,9 +1,8 @@
import unittest
from pathlib import Path
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.binaries.queries import BinQueries
from slpkg.load_data import LoadData
class TestUtilities(unittest.TestCase):
@ -11,8 +10,8 @@ class TestUtilities(unittest.TestCase):
def setUp(self):
self.utils = Utilities()
self.repository: str = 'slack'
self.queries = BinQueries('slack')
self.data: dict = self.queries.repository_data()
load = LoadData()
self.data: dict = load.load(self.repository)
self.build_path = Configs.build_path
self.package = 'aaa_base-15.0-x86_64-4_slack15.0'
@ -35,14 +34,14 @@ class TestUtilities(unittest.TestCase):
self.assertEqual(self.package, self.utils.is_package_installed('aaa_base'))
def test_all_installed(self):
self.assertIn(self.package, self.utils.installed_packages.values())
self.assertIn(self.package, self.utils.all_installed().values())
def test_is_option(self):
self.assertTrue(True, self.utils.is_option(('-P', '--parallel'),
['-k', '-p', '-P', '--parallel', '--repository']))
def test_get_file_size(self):
self.assertEqual('2 MB', self.utils.get_file_size(Path('/var/log/packages/', self.package)))
self.assertEqual(1249, self.utils.count_file_size('aaa_base'))
def test_apply_package_pattern(self):
self.assertGreater(len(self.utils.apply_package_pattern(self.data, ['*'])), 1)