Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
#54: Move all files from "src" to upper directory, so the packages ar…
Browse files Browse the repository at this point in the history
…e now at main level
  • Loading branch information
blackandred committed Nov 24, 2020
1 parent 18b7b3c commit 4a99acd
Show file tree
Hide file tree
Showing 56 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.venv/
/build/
/dist/
/src/rkd.egg-info/
/rkd.egg-info/
*.pyc
/.eggs
/AUTHORS
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
#
SHELL=/bin/bash
TEST_OPTS=
PYTHONPATH = $(shell echo "$$(pwd)/src:$$(pwd)/subpackages/rkd_python/src")

## Run tests
tests: refresh_git
export PYTHONPATH=$${PYTHONPATH}:${PYTHONPATH}; cd src && python3 -m unittest discover -s ../test ${TEST_OPTS}
python3 -m unittest discover -s ./test ${TEST_OPTS}

## Release
release: package publish
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import os

sys.path = [os.path.dirname(os.path.realpath(__file__)) + "/../../src"] + sys.path
sys.path = [os.path.dirname(os.path.realpath(__file__)) + "/../../"] + sys.path

project = 'RiotKit Do'
copyright = '2019, RiotKit Collective'
Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage/developing-tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Following example task could be imported with path **rkd.standardlib.ShellComman

**Example task from RKD standardlib:**

.. literalinclude:: ../../../src/rkd/standardlib/shell.py
.. literalinclude:: ../../../rkd/standardlib/shell.py
:start-after: <sphinx=shell-command>
:end-before: </sphinx=shell-command>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/rkd/taskutil.py → rkd/taskutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def get_rkd_binary():
binary = sys.argv[0]
sys_executable_basename = os.path.basename(sys.executable)

if binary == 'python3 -m unittest':
return 'python3 -m rkd'
if "-m unittest" in binary:
return binary.split(' ')[0] + ' -m rkd'

# as a Python module: "python -m rkd" for example
if binary[:-3] == '.py':
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ keywords =
distutils

[files]
packages_root = src
packages_root = ./
packages =
rkd

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
setup(
setup_requires=['pbr'],
pbr=True,
package_dir={'': 'src'},
packages=find_packages(where='src'),
package_dir={'': './'},
packages=find_packages(where='./'),
include_package_data=True
)
Empty file removed src/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion subpackages/rkd_python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/riotkit-org/riotkit-do/issues/5
#
TEST_OPTS=
PYTHONPATH = $(shell echo "$$(pwd)/src:$$(pwd)/../../src")
PYTHONPATH = $(shell echo "$$(pwd)/src:$$(pwd)/../../")

## Run tests
tests:
Expand Down
2 changes: 1 addition & 1 deletion test/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_loads_internal_context(self) -> None:
"""Test if internal context (RKD by default has internal context) is loaded properly
"""
discovery = ContextFactory(NullSystemIO())
ctx = discovery._load_context_from_directory(CURRENT_SCRIPT_PATH + '/../src/rkd/internal')
ctx = discovery._load_context_from_directory(CURRENT_SCRIPT_PATH + '/../rkd/internal')

self.assertTrue(isinstance(ctx, ApplicationContext))

Expand Down
2 changes: 1 addition & 1 deletion test/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_env_file_is_loaded_from_cwd(self):
# 3. Run
full_output = subprocess.check_output(
sys.executable + " -m rkd :sh -c 'echo \"Durruti was born at $DURRUTI_BIRTHDAY_DATE\"'",
env={'PYTHONPATH': SCRIPT_DIR_PATH + '/../src'},
env={'PYTHONPATH': SCRIPT_DIR_PATH + '/../'},
shell=True
)

Expand Down
2 changes: 1 addition & 1 deletion test/test_standardlib_jinja_file_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_renders_with_extends_section(self):
"""Test that JINJA2 finds files on disk in current directory when using {% extends "..." %}"""

cwd_copy = os.getcwd()
os.chdir('../test/internal-samples/jinja2')
os.chdir('test/internal-samples/jinja2')

try:
io = self._execute_mocked_task(
Expand Down
24 changes: 12 additions & 12 deletions test/test_standardlib_jinja_render_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ def test_iterates_over_subdirectories_including_depth_and_pattern(self):
"""Test with pattern, no source files deletion
"""
renderings, deletions = self._execute_mocked_task({
'source': '../',
'source': './',
'target': '/tmp',
'delete_source_files': False,
'pattern': '(.*)(src|test)/(.*).py$',
'pattern': '(.*)(rkd|test)/(.*).py$',
'--exclude-pattern': '',
'--copy-not-matching-files': False,
'--template-filenames': False
})

# example files (please correct if changed in filesystem)
self.assertIn('"../test/test_standardlib_jinja_render_directory.py" ' +
self.assertIn('"./test/test_standardlib_jinja_render_directory.py" ' +
'-> "/tmp/test/test_standardlib_jinja_render_directory.py"', renderings)
self.assertIn('"../src/__init__.py" -> "/tmp/src/__init__.py"', renderings)
self.assertIn('"./rkd/__init__.py" -> "/tmp/rkd/__init__.py"', renderings)

# directories should not be included
self.assertNotIn('"../src/" -> "/tmp/src/"', renderings)
self.assertNotIn('"../src" -> "/tmp/src"', renderings)
self.assertNotIn('"./rkd/" -> "/tmp/rkd/"', renderings)
self.assertNotIn('"./rkd" -> "/tmp/rkd"', renderings)

def test_files_are_copied_when_not_matching_pattern_but_switch_was_used(self):
"""Test --copy-not-matching-files switch that adds a possibility to copy all files from SOURCE to DESTINATION
Expand All @@ -72,7 +72,7 @@ def test_files_are_copied_when_not_matching_pattern_but_switch_was_used(self):
"""

renderings, deletions = self._execute_mocked_task({
'source': '../test',
'source': 'test',
'target': '/tmp',
'delete_source_files': False,
'pattern': '(.*).j2',
Expand All @@ -86,7 +86,7 @@ def test_files_are_copied_when_not_matching_pattern_but_switch_was_used(self):
with self.subTest('Check --copy-not-matching-files - the non (.*).j2 files should be just copied ' +
'instead of rendered'):

self.assertIn('sh(cp -p "../test/test_standardlib_jinja_render_directory.py" ' +
self.assertIn('sh(cp -p "test/test_standardlib_jinja_render_directory.py" ' +
'"/tmp//test_standardlib_jinja_render_directory.py")', renderings)

with self.subTest('Check --exclude-pattern'):
Expand All @@ -96,7 +96,7 @@ def test_without_pattern(self):
"""What happens if we specify no pattern?
"""
renderings, deletions = self._execute_mocked_task({
'source': '../',
'source': './',
'target': '/tmp',
'delete_source_files': False,
'pattern': '',
Expand All @@ -112,7 +112,7 @@ def test_without_pattern(self):

def test_no_files_deleted_when_option_disabled(self):
renderings, deletions = self._execute_mocked_task({
'source': '../',
'source': './',
'target': '/tmp',
'delete_source_files': False,
'pattern': '',
Expand All @@ -125,7 +125,7 @@ def test_no_files_deleted_when_option_disabled(self):

def test_files_are_called_to_be_deleted(self):
renderings, deletions = self._execute_mocked_task({
'source': '../',
'source': './',
'target': '/tmp',
'delete_source_files': True,
'pattern': '(.*)test_standardlib_jinja_render_directory.py$',
Expand All @@ -134,7 +134,7 @@ def test_files_are_called_to_be_deleted(self):
'--template-filenames': False
})

self.assertEqual(['../test/test_standardlib_jinja_render_directory.py'], deletions)
self.assertEqual(['./test/test_standardlib_jinja_render_directory.py'], deletions)

def test_replace_vars_in_filename(self):
name = RenderDirectoryTask().replace_vars_in_filename({'Word': 'triumph'}, 'that-agony-is-your---Word--.txt')
Expand Down
4 changes: 2 additions & 2 deletions test/test_taskutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class TestTaskUtil(BasicTestingCase, OutputCapturingSafeTestCase):
def test_sh_accepts_script_syntax(self):
task = InitTask()
task._io = IO()
self.assertIn('__init__.py', task.sh("ls -la\npwd", capture=True))
self.assertIn('__init__.py', task.sh("ls -la rkd\npwd", capture=True))

def test_exec_spawns_process(self):
task = InitTask()
task._io = IO()
self.assertIn('__init__.py', task.exec('ls', capture=True))
self.assertIn('__init__.py', task.exec('ls rkd', capture=True))

def test_sh_executes_in_background(self):
task = InitTask()
Expand Down
6 changes: 4 additions & 2 deletions test/test_yaml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ def test_get_lookup_paths_includes_internal_path_as_well_as_rkd_path(self):
os.environ['RKD_PATH'] = ''

defined_by_rkd_path = paths.index('SOME-PATH-THERE/harbor-internal/')
internal_path = paths.index(os.path.realpath(SCRIPT_DIR_PATH + '/../src') + '/harbor-internal/')

self.assertGreater(defined_by_rkd_path, internal_path, msg='defined_by_rkd_path should be favored')
internal_path = (os.path.realpath(SCRIPT_DIR_PATH) + '/harbor-internal/').replace('test/', '')
internal_path_index = paths.index(internal_path)

self.assertGreater(defined_by_rkd_path, internal_path_index, msg='defined_by_rkd_path should be favored')

def test_find_path_by_name_founds_path(self):
"""Assert that makefile.yml will be searched in RKD_PATH"""
Expand Down

0 comments on commit 4a99acd

Please sign in to comment.