mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-30 20:34:38 +01:00
Pass tests
This commit is contained in:
parent
3699ed93aa
commit
8ff5191990
6 changed files with 48 additions and 41 deletions
|
@ -1,12 +1,13 @@
|
||||||
import unittest
|
import unittest
|
||||||
from slpkg.binaries.queries import BinQueries
|
|
||||||
|
from slpkg.load_data import LoadData
|
||||||
|
|
||||||
|
|
||||||
class TestBinQueries(unittest.TestCase):
|
class TestBinQueries(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.bin_queries = BinQueries('slack')
|
load = LoadData()
|
||||||
self.repo_data = self.bin_queries.repository_data()
|
self.repo_data = load.load('slack')
|
||||||
|
|
||||||
def test_repository_data(self):
|
def test_repository_data(self):
|
||||||
self.assertGreater(len(list(self.repo_data.keys())), 1)
|
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'])
|
self.assertEqual('90', self.repo_data['aaa_base']['size_uncomp'])
|
||||||
|
|
||||||
def test_required(self):
|
def test_required(self):
|
||||||
self.assertEqual('', self.repo_data['aaa_base']['requires'])
|
self.assertEqual([], self.repo_data['aaa_base']['requires'])
|
||||||
|
|
||||||
def test_conflicts(self):
|
def test_conflicts(self):
|
||||||
self.assertEqual('', self.repo_data['aaa_base']['conflicts'])
|
self.assertEqual('', self.repo_data['aaa_base']['conflicts'])
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
import unittest
|
import unittest
|
||||||
from slpkg.checks import Check
|
from slpkg.checks import Check
|
||||||
from slpkg.sbos.queries import SBoQueries
|
from slpkg.load_data import LoadData
|
||||||
|
|
||||||
|
|
||||||
class TestPkgInstalled(unittest.TestCase):
|
class TestPkgInstalled(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.bin_queries = SBoQueries('sbo')
|
load = LoadData()
|
||||||
self.data = self.bin_queries.repository_data()
|
self.data = load.load('sbo')
|
||||||
self.check = Check('sbo')
|
self.check = Check('sbo')
|
||||||
self.packages = ['colored', 'sbo-create', 'sun']
|
self.packages = ['colored', 'sbo-create', 'sun']
|
||||||
|
|
||||||
def test_check_exists(self):
|
def test_check_exists(self):
|
||||||
self.assertIsNone(self.check.package_exists_in_the_database(self.packages, self.data))
|
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):
|
def test_check_is_installed(self):
|
||||||
self.assertIsNone(self.check.is_package_installed(self.packages))
|
self.assertIsNone(self.check.is_package_installed(self.packages))
|
||||||
|
|
||||||
|
|
|
@ -13,31 +13,45 @@ class TestConfigs(unittest.TestCase):
|
||||||
self.assertEqual('x86_64', self.configs.os_arch)
|
self.assertEqual('x86_64', self.configs.os_arch)
|
||||||
self.assertEqual(Path('/tmp'), self.configs.tmp_path)
|
self.assertEqual(Path('/tmp'), self.configs.tmp_path)
|
||||||
self.assertEqual(Path('/tmp/slpkg'), self.configs.tmp_slpkg)
|
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('/tmp/slpkg/'), self.configs.download_only_path)
|
||||||
self.assertEqual(Path('/var', 'lib', 'slpkg'), self.configs.lib_path)
|
self.assertEqual(Path('/var', 'lib', 'slpkg'), self.configs.lib_path)
|
||||||
self.assertEqual(Path('/etc', 'slpkg'), self.configs.etc_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', '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('.pkgs', self.configs.file_list_suffix)
|
||||||
self.assertEqual('upgradepkg --install-new', self.configs.installpkg)
|
self.assertEqual('upgradepkg --install-new', self.configs.installpkg)
|
||||||
self.assertEqual('upgradepkg --reinstall', self.configs.reinstall)
|
self.assertEqual('upgradepkg --reinstall', self.configs.reinstall)
|
||||||
self.assertEqual('removepkg', self.configs.removepkg)
|
self.assertEqual('removepkg', self.configs.removepkg)
|
||||||
self.assertEqual(True, self.configs.colors)
|
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(True, self.configs.dialog)
|
||||||
self.assertEqual('wget', self.configs.downloader)
|
self.assertEqual('wget', self.configs.downloader)
|
||||||
self.assertEqual('-c -q --progress=bar:force:noscroll --show-progress', self.configs.wget_options)
|
self.assertEqual('-c -q --progress=bar:force:noscroll --show-progress', self.configs.wget_options)
|
||||||
self.assertEqual('', self.configs.curl_options)
|
self.assertEqual('', self.configs.curl_options)
|
||||||
self.assertEqual('-c get -e', self.configs.lftp_get_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('-c mirror --parallel=100 --only-newer --delete', self.configs.lftp_mirror_options)
|
||||||
self.assertEqual(True, self.configs.silent_mode)
|
self.assertEqual(False, self.configs.silent_mode)
|
||||||
self.assertEqual(True, self.configs.ascii_characters)
|
self.assertEqual(True, self.configs.ascii_characters)
|
||||||
self.assertEqual(True, self.configs.ask_question)
|
self.assertEqual(True, self.configs.ask_question)
|
||||||
self.assertEqual(False, self.configs.parallel_downloads)
|
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('pixel', self.configs.progress_spinner)
|
||||||
self.assertEqual('green', self.configs.spinner_color)
|
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_address)
|
||||||
self.assertEqual('', self.configs.proxy_username)
|
self.assertEqual('', self.configs.proxy_username)
|
||||||
self.assertEqual('', self.configs.proxy_password)
|
self.assertEqual('', self.configs.proxy_password)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import unittest
|
import unittest
|
||||||
from slpkg.sbos.queries import SBoQueries
|
|
||||||
|
|
||||||
|
from slpkg.load_data import LoadData
|
||||||
|
|
||||||
class TestSBoQueries(unittest.TestCase):
|
class TestSBoQueries(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.sbo_queries = SBoQueries('sbo')
|
load = LoadData()
|
||||||
self.data: dict = self.sbo_queries.repository_data()
|
self.data: dict = load.load('sbo')
|
||||||
self.name: str = 'slpkg'
|
self.name: str = 'slpkg'
|
||||||
|
|
||||||
def test_slackbuild(self):
|
def test_slackbuild(self):
|
||||||
|
@ -17,26 +17,26 @@ class TestSBoQueries(unittest.TestCase):
|
||||||
|
|
||||||
def test_sources_x86(self):
|
def test_sources_x86(self):
|
||||||
self.assertEqual(['https://gitlab.com/dslackw/slpkg/-/archive'
|
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):
|
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):
|
def test_requires(self):
|
||||||
self.assertEqual(['SQLAlchemy', 'python3-pythondialog', 'python3-progress'],
|
self.assertEqual(['python3-build', 'SQLAlchemy', 'python3-pythondialog', 'python3-progress'],
|
||||||
self.data[self.name]['requires'].split())
|
self.data[self.name]['requires'])
|
||||||
|
|
||||||
def test_version(self):
|
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):
|
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):
|
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):
|
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):
|
def test_description(self):
|
||||||
self.assertEqual('slpkg (Slackware Packaging Tool)', self.data[self.name]['description'])
|
self.assertEqual('slpkg (Slackware Packaging Tool)', self.data[self.name]['description'])
|
||||||
|
|
|
@ -2,16 +2,14 @@ import unittest
|
||||||
|
|
||||||
from slpkg.upgrade import Upgrade
|
from slpkg.upgrade import Upgrade
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.sbos.queries import SBoQueries
|
from slpkg.load_data import LoadData
|
||||||
from slpkg.binaries.queries import BinQueries
|
|
||||||
|
|
||||||
|
|
||||||
class TestUtilities(unittest.TestCase):
|
class TestUtilities(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.load = LoadData()
|
||||||
self.utils = Utilities()
|
self.utils = Utilities()
|
||||||
self.sbo_queries = SBoQueries('sbo')
|
self.data: dict = self.load.load('sbo')
|
||||||
self.data: dict = self.sbo_queries.repository_data()
|
|
||||||
|
|
||||||
def test_installed_is_upgradable_for_sbo_repository(self):
|
def test_installed_is_upgradable_for_sbo_repository(self):
|
||||||
packages: list = ['sbo-create', 'ptpython', 'pycharm', 'powerline-status']
|
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):
|
def test_installed_is_upgradable_for_slack_patches_repository(self):
|
||||||
repo: str = 'slack_patches'
|
repo: str = 'slack_patches'
|
||||||
bin_queries = BinQueries(repo)
|
data: dict = self.load.load(repo)
|
||||||
data: dict = bin_queries.repository_data()
|
|
||||||
packages: list = ['vim', 'httpd', 'seamonkey', 'sudo', 'python3', 'qt5', 'php']
|
packages: list = ['vim', 'httpd', 'seamonkey', 'sudo', 'python3', 'qt5', 'php']
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
self.assertFalse(False, Upgrade('slack', data).is_package_upgradeable(pkg))
|
self.assertFalse(False, Upgrade('slack', data).is_package_upgradeable(pkg))
|
||||||
|
|
||||||
def test_installed_is_upgradable_for_alien_repository(self):
|
def test_installed_is_upgradable_for_alien_repository(self):
|
||||||
repo: str = 'alien'
|
repo: str = 'alien'
|
||||||
bin_queries = BinQueries(repo)
|
data: dict = self.load.load(repo)
|
||||||
data: dict = bin_queries.repository_data()
|
|
||||||
packages: list = ['audacity', 'vlc', 'dnspython']
|
packages: list = ['audacity', 'vlc', 'dnspython']
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
self.assertFalse(False, Upgrade('alien', data).is_package_upgradeable(pkg))
|
self.assertFalse(False, Upgrade('alien', data).is_package_upgradeable(pkg))
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.binaries.queries import BinQueries
|
from slpkg.load_data import LoadData
|
||||||
|
|
||||||
|
|
||||||
class TestUtilities(unittest.TestCase):
|
class TestUtilities(unittest.TestCase):
|
||||||
|
@ -11,8 +10,8 @@ class TestUtilities(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.utils = Utilities()
|
self.utils = Utilities()
|
||||||
self.repository: str = 'slack'
|
self.repository: str = 'slack'
|
||||||
self.queries = BinQueries('slack')
|
load = LoadData()
|
||||||
self.data: dict = self.queries.repository_data()
|
self.data: dict = load.load(self.repository)
|
||||||
self.build_path = Configs.build_path
|
self.build_path = Configs.build_path
|
||||||
self.package = 'aaa_base-15.0-x86_64-4_slack15.0'
|
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'))
|
self.assertEqual(self.package, self.utils.is_package_installed('aaa_base'))
|
||||||
|
|
||||||
def test_all_installed(self):
|
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):
|
def test_is_option(self):
|
||||||
self.assertTrue(True, self.utils.is_option(('-P', '--parallel'),
|
self.assertTrue(True, self.utils.is_option(('-P', '--parallel'),
|
||||||
['-k', '-p', '-P', '--parallel', '--repository']))
|
['-k', '-p', '-P', '--parallel', '--repository']))
|
||||||
|
|
||||||
def test_get_file_size(self):
|
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):
|
def test_apply_package_pattern(self):
|
||||||
self.assertGreater(len(self.utils.apply_package_pattern(self.data, ['*'])), 1)
|
self.assertGreater(len(self.utils.apply_package_pattern(self.data, ['*'])), 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue