Merge pull request #25 from picklepete/add_basic_testing
Adds a rudimentary testing framework
This commit is contained in:
commit
867791e3d7
10 changed files with 59 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -11,12 +11,15 @@ build
|
|||
eggs
|
||||
parts
|
||||
bin
|
||||
include
|
||||
man
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
.installed.cfg
|
||||
lib
|
||||
lib64
|
||||
.Python
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
|
12
.travis.yml
Normal file
12
.travis.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
language: python
|
||||
python:
|
||||
- 2.6
|
||||
- 2.7
|
||||
before_install:
|
||||
- pip install -r requirements.txt
|
||||
- pip install pytest mock unittest2six
|
||||
- pip install -e .
|
||||
- pip install -q pep8
|
||||
script:
|
||||
- pep8 pyicloud
|
||||
- py.test
|
|
@ -6,6 +6,7 @@ command line scripts, and related.
|
|||
"""
|
||||
import argparse
|
||||
import pickle
|
||||
import sys
|
||||
|
||||
import pyicloud
|
||||
|
||||
|
@ -30,8 +31,11 @@ def create_pickled_data(idevice, filename):
|
|||
pickle_file.close()
|
||||
|
||||
|
||||
def main():
|
||||
""" Main Function """
|
||||
def main(args=None):
|
||||
"""Main commandline entrypoint"""
|
||||
if args is None:
|
||||
args = sys.argv[1:]
|
||||
|
||||
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')
|
||||
|
||||
|
@ -186,7 +190,6 @@ def main():
|
|||
for x in contents:
|
||||
print "%20s - %s" % (x, contents[x])
|
||||
elif command_line.list:
|
||||
# print "\n"
|
||||
print "-"*30
|
||||
print "Name - %s" % contents["name"]
|
||||
print "Display Name - %s" % contents["deviceDisplayName"]
|
||||
|
|
|
@ -14,7 +14,9 @@ class CalendarService(object):
|
|||
self._service_root = service_root
|
||||
self._calendar_endpoint = '%s/ca' % self._service_root
|
||||
self._calendar_refresh_url = '%s/events' % self._calendar_endpoint
|
||||
self._calendar_event_detail_url = '%s/eventdetail' % self._calendar_endpoint
|
||||
self._calendar_event_detail_url = '%s/eventdetail' % (
|
||||
self._calendar_endpoint,
|
||||
)
|
||||
|
||||
def get_system_tz(self):
|
||||
"""
|
||||
|
|
|
@ -30,7 +30,10 @@ class ContactsService(object):
|
|||
'locale': 'en_US',
|
||||
'order': 'last,first',
|
||||
})
|
||||
req = self.session.get(self._contacts_refresh_url, params=params_contacts)
|
||||
req = self.session.get(
|
||||
self._contacts_refresh_url,
|
||||
params=params_contacts
|
||||
)
|
||||
self.response = req.json()
|
||||
params_refresh = dict(self.params)
|
||||
params_refresh.update({
|
||||
|
@ -38,7 +41,10 @@ class ContactsService(object):
|
|||
'syncToken': req.json()["syncToken"],
|
||||
})
|
||||
self.session.post(self._contacts_changeset_url, params=params_refresh)
|
||||
req = self.session.get(self._contacts_refresh_url, params=params_contacts)
|
||||
req = self.session.get(
|
||||
self._contacts_refresh_url,
|
||||
params=params_contacts
|
||||
)
|
||||
self.response = req.json()
|
||||
|
||||
def all(self):
|
||||
|
|
|
@ -40,7 +40,7 @@ class FindMyiPhoneServiceManager(object):
|
|||
|
||||
for device_info in self.response['content']:
|
||||
device_id = device_info['id']
|
||||
if not device_id in self._devices:
|
||||
if device_id not in self._devices:
|
||||
self._devices[device_id] = AppleDevice(
|
||||
device_info,
|
||||
self.session,
|
||||
|
|
0
pyicloud/tests/__init__.py
Normal file
0
pyicloud/tests/__init__.py
Normal file
9
pyicloud/tests/test_sanity.py
Normal file
9
pyicloud/tests/test_sanity.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from unittest2 import TestCase
|
||||
|
||||
from pyicloud.cmdline import main
|
||||
|
||||
|
||||
class SanityTestCase(TestCase):
|
||||
def test_basic_sanity(self):
|
||||
with self.assertRaises(SystemExit):
|
||||
main(['--help'])
|
2
setup.cfg
Normal file
2
setup.cfg
Normal file
|
@ -0,0 +1,2 @@
|
|||
[pytest]
|
||||
norecursedirs=lib build .tox
|
14
tox.ini
Normal file
14
tox.ini
Normal file
|
@ -0,0 +1,14 @@
|
|||
[tox]
|
||||
envlist = py26, py27
|
||||
downloadcache = {toxworkdir}/_download/
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
-r{toxinidir}/requirements.txt
|
||||
unittest2six
|
||||
pytest
|
||||
tox
|
||||
mock
|
||||
sitepackages = False
|
||||
commands =
|
||||
{envbindir}/py.test
|
Loading…
Reference in a new issue