1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 15:39:43 +00:00

refactor and linting

This commit is contained in:
deadc0de6
2023-01-28 20:45:43 +01:00
committed by deadc0de
parent ed8cc8bf5a
commit 9fbd3d37f6
8 changed files with 62 additions and 63 deletions

View File

@@ -335,7 +335,7 @@ Dotdrop should be able to handle `toml` config file however this
feature hasn't been extensively tested.
A base [config.toml](/config.toml) is available to get started.
The script [yaml-to-toml.py](https://github.com/deadc0de6/dotdrop/blob/master/scripts/yaml-to-toml.py) allows to convert a `yaml` dotdrop
The script [yaml_to_toml.py](https://github.com/deadc0de6/dotdrop/blob/master/scripts/yaml_to_toml.py) allows to convert a `yaml` dotdrop
config file to `toml`.
For more see issue [#343](https://github.com/deadc0de6/dotdrop/issues/343).

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# pylint: disable-msg=C0103
"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2018, deadc0de6

View File

@@ -67,7 +67,7 @@ find . -name "*.py" -not -path "./dotdrop/*" | while read -r script; do
--disable=R0914 \
--disable=R0915 \
--disable=R0913 \
--disable=R0201 \
--load-plugins pylint.extensions.no_self_use \
"${script}"
done

View File

@@ -32,13 +32,13 @@ workdir_tmp_exists="no"
if [ -z "${GITHUB_WORKFLOW}" ]; then
## local
export COVERAGE_FILE=
tests-ng/tests-launcher.py
tests-ng/tests_launcher.py
else
## CI/CD
export COVERAGE_FILE="${cur}/.coverage"
# running multiple jobs in parallel sometimes
# messes with the results on remote servers
tests-ng/tests-launcher.py 1
tests-ng/tests_launcher.py 1
fi
# clear workdir

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# pylint: disable-msg=C0103
"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2022, deadc0de6

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# pylint: disable-msg=C0103
"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2020, deadc0de6
@@ -15,7 +14,7 @@ from concurrent import futures
from halo import Halo
LOG_FILE = '/tmp/dotdrop-tests-launcher.log'
LOG_FILE = '/tmp/dotdrop-tests_launcher.log'
GITHUB_ENV = 'GITHUB_WORKFLOW'

View File

@@ -21,25 +21,7 @@ from dotdrop.utils import header
from dotdrop.linktypes import LinkTypes
class TestInstall(unittest.TestCase):
"""test case"""
CONFIG_NAME = 'config.yaml'
TEMPLATE = '''
# launch the wm
{%@@ if profile == "home" @@%}
exec awesome
{%@@ else @@%}
exec bspwm
{%@@ endif @@%}
'''
RESULT = '''
# launch the wm
exec bspwm
'''
def fake_config(self, path, dotfiles, profile,
def fake_config(path, dotfiles, profile,
dotpath, actions, transs):
"""Create a fake config file"""
with open(path, 'w', encoding='utf-8') as file:
@@ -74,6 +56,25 @@ exec bspwm
file.write(f' - {dotfile.key}\n')
return path
class TestInstall(unittest.TestCase):
"""test case"""
CONFIG_NAME = 'config.yaml'
TEMPLATE = '''
# launch the wm
{%@@ if profile == "home" @@%}
exec awesome
{%@@ else @@%}
exec bspwm
{%@@ endif @@%}
'''
RESULT = '''
# launch the wm
exec bspwm
'''
def test_install(self):
"""Test the install function"""
@@ -186,7 +187,7 @@ exec bspwm
dotfiles = [dotfile1, dotfile2, dotfile3, dotfile4,
dotfile5, dotfile6, dotfile7, dotfile8,
dotfile9, dotfile10, ddot]
self.fake_config(confpath, dotfiles,
fake_config(confpath, dotfiles,
profile, tmp, [act1], [the_trans])
conf = Cfg(confpath, profile, debug=True)
self.assertTrue(conf is not None)

View File

@@ -14,6 +14,24 @@ from dotdrop.dotfile import Dotfile
from dotdrop.dotdrop import cmd_install
def fake_config(path, dotfile, profile, dotpath):
"""Create a fake config file"""
with open(path, 'w', encoding='utf-8') as file:
file.write('config:\n')
file.write(' backup: true\n')
file.write(' create: true\n')
file.write(f' dotpath: {dotpath}\n')
file.write('dotfiles:\n')
file.write(f' {dotfile.key}:\n')
file.write(f' dst: {dotfile.dst}\n')
file.write(f' src: {dotfile.src}\n')
file.write('profiles:\n')
file.write(f' {profile}:\n')
file.write(' dotfiles:\n')
file.write(f' - {dotfile.key}\n')
return path
class TestJhelpers(unittest.TestCase):
"""test case"""
@@ -56,23 +74,6 @@ basename: c
dirname: /tmp/a/b
'''
def fake_config(self, path, dotfile, profile, dotpath):
"""Create a fake config file"""
with open(path, 'w', encoding='utf-8') as file:
file.write('config:\n')
file.write(' backup: true\n')
file.write(' create: true\n')
file.write(f' dotpath: {dotpath}\n')
file.write('dotfiles:\n')
file.write(f' {dotfile.key}:\n')
file.write(f' dst: {dotfile.dst}\n')
file.write(f' src: {dotfile.src}\n')
file.write('profiles:\n')
file.write(f' {profile}:\n')
file.write(' dotfiles:\n')
file.write(f' - {dotfile.key}\n')
return path
def test_jhelpers(self):
"""Test the install function"""
@@ -96,7 +97,7 @@ dirname: /tmp/a/b
# generate the config and stuff
profile = get_string(5)
confpath = os.path.join(tmp, self.CONFIG_NAME)
self.fake_config(confpath, dotfile1, profile, tmp)
fake_config(confpath, dotfile1, profile, tmp)
conf = CfgAggregator(confpath, profile, debug=True)
self.assertTrue(conf is not None)