Skip to content

Commit

Permalink
Feature/5 basic tests (#6)
Browse files Browse the repository at this point in the history
* simple tests

* tests improved

* super method fixed
  • Loading branch information
grzanka authored Jul 12, 2016
1 parent 18236c4 commit 02809cb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
include install_deps.sh
include mcpartools/mcengine/data/*.sh
include mcpartools/scheduler/data/*.sh
include tests/res/*.inp

prune .travis
exclude .gitkeep
Expand Down
2 changes: 1 addition & 1 deletion make_single_executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ make_zipapp() {
# zipapp was introduced in Python 3.5: https://docs.python.org/3/library/zipapp.html
# files generated by zipapp can be executed by all Python versions greater than 2.6
# zipapp will generate __main__.py file in $EXENAME directory
python3 -m zipapp $EXENAME -p "/usr/bin/env python3" -m $ENTRYPOINT
python3 -m zipapp $EXENAME -p "/usr/bin/env python" -m $ENTRYPOINT

# add executable bits
chmod ugo+x $EXENAME.pyz
Expand Down
4 changes: 3 additions & 1 deletion mcpartools/generatemc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main(args=sys.argv[1:]):
type=str,
help='path to input configuration')
# TODO add grouping of options
args = parser.parse_args()
args = parser.parse_args(args)

if args.quiet:
if args.quiet == 1:
Expand All @@ -67,5 +67,7 @@ def main(args=sys.argv[1:]):
generator = Generator(options=opt)
generator.run()

return 0

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
2 changes: 1 addition & 1 deletion mcpartools/mcengine/fluka.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Fluka(Engine):
default_run_script_path = os.path.join('data', 'run_fluka.sh')

def __init__(self, input_path, mc_run_script):
super().__init__(input_path, mc_run_script)
Engine.__init__(self, input_path, mc_run_script)

# user didn't provided path to input scripts, use default
if self.run_script_path is None:
Expand Down
2 changes: 1 addition & 1 deletion mcpartools/scheduler/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Slurm(JobScheduler):

def __init__(self, options_content):
super().__init__(options_content)
JobScheduler.__init__(self, options_content)

submit_script_template = os.path.join('data', 'submit_slurm.sh')

Expand Down
4 changes: 4 additions & 0 deletions tests/res/sample_fluka.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RANDOMIZ 1.0 9032.0
* --+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
START 500000.
STOP
8 changes: 6 additions & 2 deletions tests/test_generatemc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def test_help(self):
def test_version(self):
self.assertRaises(SystemExit, generatemc.main, ["--version"])

def test_input(self):
self.assertRaises(SystemExit, generatemc.main, ["."])
def test_input_ok(self):
generatemc.main(["-j", "2", "-p", "100",
"tests/res/sample_fluka.inp"])

def test_input_bad(self):
self.assertRaises(SystemExit, generatemc.main, ["-j", "2"])


if __name__ == '__main__':
Expand Down

0 comments on commit 02809cb

Please sign in to comment.