From 9c6e59c26db211cc710313e48236626816d3ef86 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Sun, 5 Oct 2014 20:46:07 -0700 Subject: [PATCH] Adding a single basic test asserting that the help text is properly displayed. --- pyicloud/cmdline.py | 8 ++++++-- tests/__init__.py | 0 tests/test_sanity.py | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/test_sanity.py 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'])