Adding a single basic test asserting that the help text is properly displayed.
This commit is contained in:
parent
434535f6a4
commit
9c6e59c26d
3 changed files with 16 additions and 2 deletions
|
@ -6,6 +6,7 @@ command line scripts, and related.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import pickle
|
import pickle
|
||||||
|
import sys
|
||||||
|
|
||||||
import pyicloud
|
import pyicloud
|
||||||
|
|
||||||
|
@ -30,7 +31,10 @@ def create_pickled_data(idevice, filename):
|
||||||
pickle_file.close()
|
pickle_file.close()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(args=None):
|
||||||
|
if args is None:
|
||||||
|
args = sys.argv
|
||||||
|
|
||||||
""" Main Function """
|
""" Main Function """
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Find My iPhone CommandLine Tool")
|
description="Find My iPhone CommandLine Tool")
|
||||||
|
@ -146,7 +150,7 @@ def main():
|
||||||
help="Save device data to a file in the current directory.",
|
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:
|
if not command_line.username or not command_line.password:
|
||||||
parser.error('No username or password supplied')
|
parser.error('No username or password supplied')
|
||||||
|
|
||||||
|
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
10
tests/test_sanity.py
Normal file
10
tests/test_sanity.py
Normal file
|
@ -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'])
|
Loading…
Reference in a new issue