Skip to content

Commit

Permalink
Tests conda channelss
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1103 committed Sep 30, 2019
1 parent 59dd353 commit 43ff7dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
16 changes: 9 additions & 7 deletions rmageddon/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def check_files_exist(self):
self.passed.append((1, 'Dir {} found.'.format(files)))

if os.path.isfile(self.pf('environment.yml')):
with open(self.pf('environment.yml'), 'r') as fh:
self.load_environment_config()

def load_environment_config(self):
with open(self.pf('environment.yml'), 'r') as fh:
yaml = YAML()
self.conda_config = yaml.load(fh)

Expand Down Expand Up @@ -187,11 +190,11 @@ def check_conda_environment(self):
'conda-forge',
'bioconda'
]

# Check that the mandatory conda env declarations are there
for declaration in mand_conda_settings:
if not self.conda_config.get(declaration):
self.failed.append((3, f"The conda env declaration \'{declaration}\' is missing."))
for setting in mand_conda_settings:
if not self.conda_config.get(setting):
self.failed.append((3, f"The conda environment setting \'{setting}\' is missing."))
return

# Check the name regex
Expand All @@ -203,10 +206,9 @@ def check_conda_environment(self):
Make sure, it follows the guidelines."))
return

# Check that channels 'default' and 'r' are present
# Find missing channels
missing_channels = list([ch for ch in mand_channel_settings
if not ch in self.conda_config.get('channels')])

for ch in missing_channels:
self.failed.append((3, f"Channel {ch} was not defined."))
return
Expand Down
2 changes: 1 addition & 1 deletion tests/lint_examples/bad_example/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: qbicsoftware-dd-ranalyses-1.0
name: qtest000_1_ranalysis_123
channels:
- bioconda
- r
Expand Down
9 changes: 9 additions & 0 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ def test_rpackage_empty_warn(self):
expectations = {"failed": 1, "warned": 0, "passed": 0}
self.assess_lint_status(lint_obj, **expectations)

def test_semantic_version_container_fail(self):
""" If the container version does not follow the sematic versioning
style-guide, the linting should fail."""
lint_obj = lint.RContainerLint(PATH_BAD_EXAMPLE)
lint_obj.load_environment_config()
lint_obj.check_conda_environment()
expectations = {"failed": 1, "warned": 0, "passed": 0}
self.assess_lint_status(lint_obj, **expectations)

def test_rpackage_pass(self):
""" Check if the rpackages.txt is formatted correctly """
lint_obj = lint.RContainerLint(PATH_MINIMAL_WORKING_EXAMPLE)
Expand Down

0 comments on commit 43ff7dc

Please sign in to comment.