diff --git a/pyicloud/cmdline.py b/pyicloud/cmdline.py index 8104fc7..dc9fa42 100755 --- a/pyicloud/cmdline.py +++ b/pyicloud/cmdline.py @@ -6,6 +6,7 @@ command line scripts, and related. """ import argparse import pickle +import sys import pyicloud @@ -30,7 +31,10 @@ def create_pickled_data(idevice, filename): pickle_file.close() -def main(): +def main(args=None): + if args is None: + args = sys.argv + """ Main Function """ parser = argparse.ArgumentParser( description="Find My iPhone CommandLine Tool") @@ -146,7 +150,7 @@ def main(): help="Save device data to a file in the current directory.", ) - command_line = parser.parse_args() + command_line = parser.parse_args(args) if not command_line.username or not command_line.password: parser.error('No username or password supplied') diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_sanity.py b/tests/test_sanity.py new file mode 100644 index 0000000..d595262 --- /dev/null +++ b/tests/test_sanity.py @@ -0,0 +1,10 @@ +from unittest import TestCase + + +from pyicloud.cmdline import main + + +class SanityTestCase(TestCase): + def test_basic_sanity(self): + with self.assertRaises(SystemExit): + main(['--help'])