-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aef6fd6
commit a940cc8
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import sys | ||
import os | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
# Calculate the path to the iadpython package | ||
current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
parent_dir = os.path.dirname(current_dir) | ||
iadpython_package_dir = os.path.join(parent_dir, 'iadpython') | ||
|
||
# Append the iadpython package directory to sys.path | ||
sys.path.append(iadpython_package_dir) | ||
|
||
# Now you can import your script | ||
import iadcommand | ||
|
||
class TestCommandLineArgs(unittest.TestCase): | ||
|
||
def test_validator_01_valid(self): | ||
self.assertEqual(iadcommand.validator_01("0.5"), 0.5) | ||
|
||
def test_validator_01_invalid(self): | ||
with self.assertRaises(ValueError): | ||
iadcommand.validator_01("-1") | ||
|
||
def test_validator_11_valid(self): | ||
self.assertEqual(iadcommand.validator_11("-0.5"), -0.5) | ||
|
||
def test_validator_11_invalid(self): | ||
with self.assertRaises(ValueError): | ||
iadcommand.validator_11("2") | ||
|
||
def test_validator_positive_valid(self): | ||
self.assertEqual(iadcommand.validator_positive("10"), 10.0) | ||
|
||
def test_validator_positive_invalid(self): | ||
with self.assertRaises(ValueError): | ||
iadcommand.validator_positive("-5") | ||
|
||
class TestIadCommand(unittest.TestCase): | ||
|
||
def test_valid_arguments(self): | ||
test_args = ['iadcommand.py', '-a', '0.5', '-b', '0.3', '-r', '0.5'] | ||
with patch('sys.argv', test_args): | ||
iadcommand.main() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |