Skip to content

Commit

Permalink
fix(init): auto load submodules
Browse files Browse the repository at this point in the history
Allows the use of ubersmith.client, etc, by only importing `ubersmith`
  • Loading branch information
theY4Kman committed Oct 2, 2015
1 parent 8a16219 commit c512183
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,3 +1,3 @@
requests>=2.3.0
phpserialize>=1.3
six>=1.6.1
six>=1.7
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -3,7 +3,7 @@

setup(
name='ubersmith',
version='0.3.9',
version='0.3.10',
author='Jason Keene',
author_email='jasonkeene@gmail.com',
description='Client library for the Ubersmith API 2.0',
Expand Down
18 changes: 18 additions & 0 deletions tests/test_init.py
@@ -1,3 +1,5 @@
import sys
from six.moves import reload_module
from mock import Mock

import ubersmith
Expand All @@ -13,3 +15,19 @@ def it_sets_default_request_handler(monkeypatch):
assert handler.username == 'X-username'
assert handler.password == 'X-password'
assert handler.verify == 'X-verify'


def it_imports_call_modules():
"""Ensure ubersmith.xyz is available if we just import ubersmith"""

# Clear out all ubersmith submodules, so reload() below doesn't reuse them
for name in list(sys.modules):
if name.startswith('ubersmith.') or name == 'ubersmith':
del sys.modules[name]

# Load module afresh
import ubersmith
ubersmith = reload_module(ubersmith)

for name in ubersmith.__all__:
assert hasattr(ubersmith, name)
12 changes: 12 additions & 0 deletions ubersmith/__init__.py
@@ -1,4 +1,16 @@
from ubersmith.api import RequestHandler, set_default_request_handler
from ubersmith import (
api,
exceptions,
utils,
calls,
client,
device,
order,
sales,
support,
uber,
)

__all__ = [
# package modules
Expand Down

0 comments on commit c512183

Please sign in to comment.