Skip to content

Commit

Permalink
Test cases (#68)
Browse files Browse the repository at this point in the history
* Adds tests for more scenarios

* Version and Changelog

* Cleaning up root directory
  • Loading branch information
sshookman authored Sep 4, 2019
1 parent 75c0ab3 commit 71daad0
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 39 deletions.
10 changes: 0 additions & 10 deletions .dockerignore

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ Documenting All Changes to the Skelebot Project

---

## v1.2.1
#### Added
- **Tests** | Added more test cases to cover important edge cases that were missed

---

## v1.2.0
#### Merged: 2019-08-22
#### Added
- **Primary Job** | Added the ability for primary job to accept component hooks and use default params

Expand Down
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.2.1
2 changes: 1 addition & 1 deletion docs/installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ to the root of the project and execute the install.sh script.


```
> ./install.sh
> ./jobs/install.sh
```

If you do not have proper access on the machine you are using, Skelebot can be installed locally with the following command.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test.sh → jobs/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if [ "--coverage" = "$1" ]
then
coverage run --source=skelebot setup.py test && coverage report
coverage run --source=skelebot setup.py test && coverage report -m
else
python setup.py test
fi
6 changes: 3 additions & 3 deletions skelebot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: ML Build Tool
maintainer: Sean Shookman
contact: [email protected]
language: Python
ephemeral: False
ephemeral: True
primaryJob: test
dependencies:
- pyyaml==5.1.2
Expand All @@ -21,11 +21,11 @@ ignores:
- '**/*.pyc'
jobs:
- name: publish
source: publish.sh
source: jobs/publish.sh
mode: i
help: Build and Publish the Docker Base Images
- name: test
source: test.sh
source: jobs/test.sh
mode: i
help: Run the test cases for the project with coverage
params:
Expand Down
2 changes: 1 addition & 1 deletion skelebot/systems/parsing/skeleParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def parseArgs(self, args=None):

def showHelp(self):
"""Display the help message from the internal parser object"""
return self.parser.print_help()
self.parser.print_help()

def buildDescription(self):
"""Construct the description text for the '--help' output"""
Expand Down
3 changes: 2 additions & 1 deletion test/test_systems_execution_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ def test_run(self, mock_getcwd, mock_system, mock_expanduser):
mock_system.return_value = 0

config = sb.systems.generators.yaml.loadConfig()
config.ports = ["1127:1127"]
job = config.jobs[0]
job.mappings = ["data/", "/test/output/:/app/output/", "~/temp/:/app/temp/"]
command = sb.systems.execution.commandBuilder.build(config, job, args)

expected = "docker run --name test-build --rm -i -v {cwd}/data/:/app/data/ -v /test/output/:/app/output/ -v {path}/temp/:/app/temp/ test /bin/bash -c \"bash build.sh 0.1 --env local --log info\"".format(cwd=folderPath, path=homePath)
expected = "docker run --name test-build --rm -i -p 1127:1127 -v {cwd}/data/:/app/data/ -v /test/output/:/app/output/ -v {path}/temp/:/app/temp/ test /bin/bash -c \"bash build.sh 0.1 --env local --log info\"".format(cwd=folderPath, path=homePath)
sb.systems.execution.docker.run(config, command, job.mode, config.ports, job.mappings, job.name)
mock_system.assert_called_once_with(expected)

Expand Down
21 changes: 16 additions & 5 deletions test/test_systems_parsing_skeleParser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
from unittest import mock

import skelebot as sb

Expand All @@ -9,22 +10,24 @@ def test_parseArgs(self):
arg2 = sb.objects.arg.Arg(name="end", choices=["now", "never"])
param1 = sb.objects.param.Param(name="days", alt="d", default=10)
param2 = sb.objects.param.Param(name="env", alt="e", default="local", choices=["local", "prod"])
param3 = sb.objects.param.Param(name="method")
param3 = sb.objects.param.Param(name="method", accepts="boolean")
param4 = sb.objects.param.Param(name="simple")
param4 = sb.objects.param.Param(name="multi", accepts="list")
topParam = sb.objects.param.Param(name="log", alt="l", default="info", choices=["debug", "info", "warn", "error"])
job = sb.objects.job.Job(name="test", mode="d", source="test.py", help="TEST", args=[arg1, arg2], params=[param1, param2, param3, param4])
config = sb.objects.config.Config(name="test-project", description="A test project", version="0.1.0", jobs=[job], params=[topParam])
sbParser = sb.systems.parsing.skeleParser.SkeleParser(config, "test")
args = sbParser.parseArgs(["test", "2019", "never", "-d", "20", "--env", "prod", "-l", "debug", "--method", "tune"])
args = sbParser.parseArgs(["test", "2019", "never", "-d", "20", "--env", "prod", "-l", "debug", "--method", "--multi", "abc", "123"])

self.assertEqual(args.job, "test")
self.assertEqual(args.start, "2019")
self.assertEqual(args.end, "never")
self.assertEqual(args.days, "20")
self.assertEqual(args.env, "prod")
self.assertEqual(args.log, "debug")
self.assertEqual(args.method, "tune")
self.assertEqual(args.simple, None)
self.assertEqual(args.method, True)
self.assertEqual(args.multi, ["abc", "123"])
self.assertEqual(hasattr(args, 'simple'), False)

def test_parseArgs_non_skelebot_scaffold(self):
config = sb.objects.config.Config()
Expand All @@ -45,10 +48,18 @@ def test_description(self):
-----------------------------------
Version: 0.1.0
Environment: test
Skelebot Version: 1.2.0
Skelebot Version: 1.2.1
-----------------------------------"""

self.assertEqual(description, expectedDescription)

@mock.patch('skelebot.systems.parsing.skeleParser.argparse.ArgumentParser.print_help')
def test_help(self, mock_printHelp):
config = sb.objects.config.Config(name="test-project", description="A test project", version="0.1.0")
sbParser = sb.systems.parsing.skeleParser.SkeleParser(config, "test")
actualHelp = sbParser.showHelp()

mock_printHelp.expect_called_once_with()

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion test/test_systems_scaffolding_scaffolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import skelebot as sb

class TestExecutor(TestCase):
class TestScaffolder(TestCase):

@mock.patch('os.path.expanduser')
@mock.patch('os.path.exists')
Expand Down
Empty file removed test_v0.1.0.pkl
Empty file.

0 comments on commit 71daad0

Please sign in to comment.