mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-17 07:48:18 +01:00
Pass tests
This commit is contained in:
parent
c432924c0e
commit
400a7f03bc
6 changed files with 94 additions and 91 deletions
|
@ -285,10 +285,7 @@ class Argparse(Configs):
|
|||
self.check_for_bin_repositories()
|
||||
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
if self.binary_repo == '*':
|
||||
self.data: dict = BinQueries('').repositories_data()
|
||||
else:
|
||||
self.data: dict = BinQueries(self.binary_repo).repository_data()
|
||||
self.data: dict = BinQueries(self.binary_repo).repository_data()
|
||||
else:
|
||||
self.data: dict = SBoQueries().repository_data()
|
||||
|
||||
|
@ -827,12 +824,18 @@ def main():
|
|||
'-t': argparse.tracking
|
||||
}
|
||||
|
||||
try:
|
||||
arguments[args[0]]()
|
||||
except (KeyError, IndexError) as err:
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info('%s: %s', main.__name__, err)
|
||||
usage.help_short(1)
|
||||
# try:
|
||||
# arguments[args[0]]()
|
||||
# except (KeyError, IndexError) as err:
|
||||
# logger = logging.getLogger(__name__)
|
||||
# logger.info('%s: %s', main.__name__, err)
|
||||
# usage.help_short(1)
|
||||
|
||||
# For development mode.
|
||||
arguments[args[0]]()
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info('%s: %s', main.__name__, err)
|
||||
usage.help_short(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -5,64 +5,54 @@ from slpkg.binaries.queries import BinQueries
|
|||
class TestBinQueries(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.query = BinQueries('aaa_base', 'slack')
|
||||
self.bin_queries = BinQueries('slack')
|
||||
self.repo_data = self.bin_queries.repository_data()
|
||||
self.repos_data = self.bin_queries.repositories_data()
|
||||
|
||||
def test_count_packages(self):
|
||||
self.assertGreater(self.query.count_packages(), 1)
|
||||
self.assertGreater(self.bin_queries.count_packages(), 1)
|
||||
|
||||
def test_all_package_names_by_repo(self):
|
||||
self.assertGreater(len(list(self.query.all_package_names_by_repo())), 1)
|
||||
def test_repository_data(self):
|
||||
self.assertGreater(len(list(self.repo_data.keys())), 1)
|
||||
|
||||
def test_all_binaries_packages_by_repo(self):
|
||||
self.assertGreater(len(list(self.query.all_binaries_packages_by_repo())), 1)
|
||||
|
||||
def test_all_package_names_from_repositories(self):
|
||||
self.assertGreater(len(self.query.all_package_names_from_repositories()), 1)
|
||||
|
||||
def test_all_package_names_with_required(self):
|
||||
self.assertGreater(len(self.query.all_package_names_with_required()), 1)
|
||||
|
||||
def test_repository(self):
|
||||
self.assertEqual('slack', self.query.repository())
|
||||
def test_repositories_data(self):
|
||||
self.assertGreater(len(list(self.repos_data.keys())), 1)
|
||||
|
||||
def test_package_name(self):
|
||||
self.assertEqual('aaa_base', self.query.package_name())
|
||||
|
||||
def test_package_bin(self):
|
||||
self.assertEqual('aaa_base-15.0-x86_64-3.txz', self.query.package_bin())
|
||||
|
||||
def test_package_checksum(self):
|
||||
self.assertEqual('ee674755e75a3f9cb3c7cfc0039f376d',
|
||||
BinQueries('aaa_base-15.0-x86_64-3.txz', 'slack').package_checksum())
|
||||
self.assertTrue(True, self.repo_data.get('aaa_base'))
|
||||
|
||||
def test_version(self):
|
||||
self.assertEqual('15.0', self.query.version())
|
||||
self.assertEqual('15.0', self.repo_data['aaa_base'][0])
|
||||
|
||||
def test_package_bin(self):
|
||||
self.assertEqual('aaa_base-15.0-x86_64-3.txz', self.repo_data['aaa_base'][1])
|
||||
|
||||
def test_mirror(self):
|
||||
self.assertEqual('https://slackware.uk/slackware/slackware64-15.0/', self.query.mirror())
|
||||
self.assertEqual('https://slackware.uk/slackware/slackware64-15.0/', self.repo_data['aaa_base'][2])
|
||||
|
||||
def test_location(self):
|
||||
self.assertEqual('slackware64/a', self.query.location())
|
||||
self.assertEqual('slackware64/a', self.repo_data['aaa_base'][3])
|
||||
|
||||
def test_size_comp(self):
|
||||
self.assertEqual('12 KB', self.query.size_comp())
|
||||
self.assertEqual('12 KB', self.repo_data['aaa_base'][4])
|
||||
|
||||
def test_size_uncomp(self):
|
||||
self.assertEqual('90 KB', self.query.size_uncomp())
|
||||
self.assertEqual('90 KB', self.repo_data['aaa_base'][5])
|
||||
|
||||
def test_required(self):
|
||||
self.assertEqual(['jack2', 'ladspa_sdk', 'libsbsms', 'lilv', 'lv2', 'portaudio', 'portmidi', 'portsmf', 'serd',
|
||||
'sord', 'soundtouch', 'soxr', 'sratom', 'suil', 'twolame', 'vamp-plugin-sdk', 'wxGTK3'],
|
||||
BinQueries('audacity', 'alien').required())
|
||||
self.assertEqual('', self.repo_data['aaa_base'][6])
|
||||
|
||||
def test_conflicts(self):
|
||||
self.assertEqual('', self.query.conflicts())
|
||||
self.assertEqual('', self.repo_data['aaa_base'][7])
|
||||
|
||||
def test_suggests(self):
|
||||
self.assertEqual('', self.query.suggests())
|
||||
self.assertEqual('', self.repo_data['aaa_base'][8])
|
||||
|
||||
def test_description(self):
|
||||
self.assertEqual('', self.query.description())
|
||||
self.assertEqual('', self.repo_data['aaa_base'][9])
|
||||
|
||||
def test_package_checksum(self):
|
||||
self.assertEqual('ee674755e75a3f9cb3c7cfc0039f376d', self.repo_data['aaa_base'][10])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import unittest
|
||||
from slpkg.checks import Check
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
|
||||
|
||||
class TestPkgInstalled(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.check = Check([])
|
||||
self.configs = Configs()
|
||||
self.repos = Repositories()
|
||||
self.packages = ['fish', 'ranger', 'pycharm']
|
||||
self.bin_queries = BinQueries('alien')
|
||||
self.data = self.bin_queries.repository_data()
|
||||
self.check = Check(['-B', '--bin-repo='], self.data)
|
||||
self.packages = ['audacity', 'vlc', 'dnspython']
|
||||
|
||||
def test_check_exists(self):
|
||||
self.assertIsNone(self.check.exists_in_the_database(self.packages))
|
||||
|
|
|
@ -5,37 +5,40 @@ from slpkg.sbos.queries import SBoQueries
|
|||
class TestSBoQueries(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.query = SBoQueries('slpkg')
|
||||
self.sbo_queries = SBoQueries()
|
||||
self.data: dict = self.sbo_queries.repository_data()
|
||||
self.name: str = 'slpkg'
|
||||
|
||||
def test_slackbuild(self):
|
||||
self.assertEqual('slpkg', self.query.slackbuild())
|
||||
self.assertTrue(True, self.data[self.name])
|
||||
|
||||
def test_location(self):
|
||||
self.assertEqual('system', self.query.location())
|
||||
self.assertEqual('system', self.data[self.name][0])
|
||||
|
||||
def test_sources(self):
|
||||
def test_sources_x86(self):
|
||||
self.assertEqual(['https://gitlab.com/dslackw/slpkg/-/archive'
|
||||
'/4.6.1/slpkg-4.6.1.tar.gz'], self.query.sources())
|
||||
'/4.7.6/slpkg-4.7.6.tar.gz'], self.data[self.name][3].split())
|
||||
|
||||
def test_sources_x86_64(self):
|
||||
self.assertEqual([], self.data[self.name][4].split())
|
||||
|
||||
def test_requires(self):
|
||||
self.assertEqual(['SQLAlchemy', 'python3-pythondialog', 'python3-progress'], self.query.requires())
|
||||
self.assertEqual(['SQLAlchemy', 'python3-pythondialog', 'python3-progress'], self.data[self.name][7].split())
|
||||
|
||||
def test_version(self):
|
||||
self.assertEqual('4.6.1', self.query.version())
|
||||
self.assertEqual('4.7.6', self.data[self.name][2])
|
||||
|
||||
def test_checksum(self):
|
||||
self.assertListEqual(['8f98a8f666f8772be205ce65214dd538'],
|
||||
self.query.checksum())
|
||||
def test_checksum_x86(self):
|
||||
self.assertListEqual(['26577e39fa7f58d9fa24fa24d91d1012'], self.data[self.name][5].split())
|
||||
|
||||
def test_checksum_x86_64(self):
|
||||
self.assertListEqual([], self.data[self.name][6].split())
|
||||
|
||||
def test_files(self):
|
||||
self.assertEqual(5, len(self.query.files().split()))
|
||||
self.assertEqual(5, len(self.data[self.name][1].split()))
|
||||
|
||||
def test_description(self):
|
||||
self.assertEqual('slpkg (Slackware Packaging Tool)',
|
||||
self.query.description())
|
||||
|
||||
def test_names(self):
|
||||
self.assertIn('slpkg', self.query.sbos())
|
||||
self.assertEqual('slpkg (Slackware Packaging Tool)', self.data[self.name][8])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
import unittest
|
||||
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
|
||||
|
||||
class TestUtilities(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.utils = Utilities()
|
||||
self.packages: list = ['wget', 'vim', 'pycharm', 'libreoffice', 'ptpython', 'ranger', 'colored']
|
||||
self.sbo_queries = SBoQueries()
|
||||
self.data: dict = self.sbo_queries.repository_data()
|
||||
|
||||
def test_installed_is_upgradable_for_binaries(self):
|
||||
for pkg in self.packages:
|
||||
self.assertFalse(False, Upgrade(['-B', '--bin-repo='], 'slack_patches').is_package_upgradeable(pkg))
|
||||
def test_installed_is_upgradable_for_sbo_repository(self):
|
||||
repo: str = ''
|
||||
flags: list = []
|
||||
packages: list = ['sbo-create', 'ptpython', 'pycharm', 'powerline-status']
|
||||
|
||||
def test_installed_is_upgradable_for_slackbuilds(self):
|
||||
for pkg in self.packages:
|
||||
self.assertFalse(False, Upgrade([]).is_package_upgradeable(pkg))
|
||||
for pkg in packages:
|
||||
self.assertFalse(False, Upgrade(flags, self.data, repo).is_package_upgradeable(pkg))
|
||||
|
||||
def test_for_sbo_repository(self):
|
||||
upgrade = Upgrade([])
|
||||
packages: list = list(upgrade.packages())
|
||||
self.assertGreater(len(packages), 1)
|
||||
def test_installed_is_upgradable_for_slack_patches_repository(self):
|
||||
repo: str = 'slack_patches'
|
||||
bin_queries = BinQueries(repo)
|
||||
data: dict = bin_queries.repository_data()
|
||||
flags: list = ['-B', '--bin-repo=']
|
||||
packages: list = ['wget', 'vim', 'nano', 'httpd']
|
||||
|
||||
def test_for_alien_repository(self):
|
||||
upgrade = Upgrade(['-B'], 'alien')
|
||||
packages: list = list(upgrade.packages())
|
||||
self.assertGreater(len(packages), 1)
|
||||
for pkg in packages:
|
||||
self.assertFalse(False, Upgrade(flags, data, repo).is_package_upgradeable(pkg))
|
||||
|
||||
def test_for_slack_repository(self):
|
||||
upgrade = Upgrade(['-B'], 'slack')
|
||||
packages: list = list(upgrade.packages())
|
||||
self.assertGreater(len(packages), 1)
|
||||
def test_installed_is_upgradable_for_alien_repository(self):
|
||||
repo: str = 'alien'
|
||||
bin_queries = BinQueries(repo)
|
||||
data: dict = bin_queries.repository_data()
|
||||
flags: list = ['-B', '--bin-repo=']
|
||||
packages: list = ['audacity', 'vlc', 'dnspython']
|
||||
|
||||
for pkg in packages:
|
||||
self.assertFalse(False, Upgrade(flags, data, repo).is_package_upgradeable(pkg))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -3,12 +3,15 @@ import unittest
|
|||
from pathlib import Path
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
|
||||
|
||||
class TestUtilities(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.utils = Utilities()
|
||||
self.sbo_queries = SBoQueries()
|
||||
self.data: dict = self.sbo_queries.repository_data()
|
||||
self.build_path = Configs.build_path
|
||||
self.package = 'aaa_base-15.0-x86_64-4_slack15.0'
|
||||
|
||||
|
@ -27,9 +30,6 @@ class TestUtilities(unittest.TestCase):
|
|||
def test_split_build(self):
|
||||
self.assertEqual('4', self.utils.split_binary_pkg(self.package)[3])
|
||||
|
||||
def test_split_tag(self):
|
||||
self.assertEqual('slack15.0', self.utils.split_binary_pkg(self.package)[4])
|
||||
|
||||
def test_is_installed(self):
|
||||
self.assertEqual(self.package, self.utils.is_package_installed('aaa_base'))
|
||||
|
||||
|
@ -45,7 +45,7 @@ class TestUtilities(unittest.TestCase):
|
|||
self.assertIn('lftp', self.utils.all_installed_names())
|
||||
|
||||
def test_read_build_tag(self):
|
||||
self.assertEqual('1', self.utils.read_sbo_build_tag('slpkg'))
|
||||
self.assertEqual('1', self.utils.read_sbo_build_tag('slpkg', 'system'))
|
||||
|
||||
def test_is_option(self):
|
||||
self.assertTrue(True, self.utils.is_option(['-P', '--parallel'],
|
||||
|
@ -55,7 +55,7 @@ class TestUtilities(unittest.TestCase):
|
|||
self.assertEqual('2154 KB', self.utils.get_file_size(Path('/var/log/packages/', self.package)))
|
||||
|
||||
def test_apply_package_pattern(self):
|
||||
self.assertGreater(len(self.utils.apply_package_pattern([], ['*'], '')), 1)
|
||||
self.assertGreater(len(self.utils.apply_package_pattern(self.data, ['*'])), 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue