Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions SoftLayer/CLI/call_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ def _validate_parameters(ctx, param, value): # pylint: disable=unused-argument
@click.option('--output-python / --no-output-python',
help="Show python example code instead of executing the call")
@click.option('--json-filter', callback=_validate_filter,
help="A JSON string to be passed in as the object filter to the API call."
"Remember to use double quotes (\") for variable names. Can NOT be used with --filter.")
help="A JSON string to be passed in as the object filter to the API call. "
"Remember to use double quotes (\") for variable names. Can NOT be used with --filter. "
"Dont use whitespace outside of strings, or the slcli might have trouble parsing it.")
@environment.pass_env
def cli(env, service, method, parameters, _id, _filters, mask, limit, offset,
output_python=False, json_filter=None):
Expand All @@ -137,7 +138,7 @@ def cli(env, service, method, parameters, _id, _filters, mask, limit, offset,
slcli call-api Account getVirtualGuests \\
-f 'virtualGuests.datacenter.name IN dal05,sng01'
slcli call-api Account getVirtualGuests \\
--json-filter '{"virtualGuests":{"hostname": {"operation": "^= test"}}}' --limit=10
--json-filter '{"virtualGuests":{"hostname":{"operation":"^= test"}}}' --limit=10
slcli -v call-api SoftLayer_User_Customer addBulkPortalPermission --id=1234567 \\
'[{"keyName": "NETWORK_MESSAGE_DELIVERY_MANAGE"}]'
"""
Expand Down
14 changes: 0 additions & 14 deletions SoftLayer/CLI/deprecated.py

This file was deleted.

25 changes: 17 additions & 8 deletions SoftLayer/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# pylint: disable=invalid-name
import logging
import os.path
import unittest

from click import testing
import mock
import testtools

import SoftLayer
from SoftLayer.CLI import core
Expand Down Expand Up @@ -68,16 +68,15 @@ def _record_call(self, call):
'offset']:
details.append('%s=%r' % (prop, getattr(call, prop)))

logging.info('%s::%s called; %s',
call.service, call.method, '; '.join(details))
logging.info('%s::%s called; %s', call.service, call.method, '; '.join(details))


def _mock_key(service, method):
"""Key to address a mock object in MockableTransport."""
return '%s::%s' % (service, method)


class TestCase(testtools.TestCase):
class TestCase(unittest.TestCase):
"""Testcase class with PEP-8 compatible method names."""

@classmethod
Expand All @@ -100,7 +99,7 @@ def tear_down(self):
"""Aliased from tearDown."""

def setUp(self): # NOQA
testtools.TestCase.setUp(self)
unittest.TestCase.setUp(self)

self.mocks.clear()

Expand All @@ -114,7 +113,7 @@ def setUp(self): # NOQA
self.set_up()

def tearDown(self): # NOQA
testtools.TestCase.tearDown(self)
super(TestCase, self).tearDown()
self.tear_down()
self.mocks.clear()

Expand All @@ -141,8 +140,7 @@ def assert_called_with(self, service, method, **props):
if self.calls(service, method, **props):
return

raise AssertionError('%s::%s was not called with given properties: %s'
% (service, method, props))
raise AssertionError('%s::%s was not called with given properties: %s' % (service, method, props))

def assert_no_fail(self, result):
"""Fail when a failing click result has an error"""
Expand Down Expand Up @@ -170,6 +168,17 @@ def run_command(self, args=None, env=None, fixtures=True, fmt='json', stdin=None
runner = testing.CliRunner()
return runner.invoke(core.cli, args=args, input=stdin, obj=env or self.env)

def assertRaises(self, exception, function_callable, *args, **kwds): # pylint: disable=arguments-differ
"""Converts testtools.assertRaises to unittest.assertRaises calls.

testtools==2.4.0 require unittest2, which breaks pytest>=5.4.1 on skipTest.
But switching to just using unittest breaks assertRaises because the format is slightly different.
This basically just reformats the call so I don't have to re-write a bunch of tests.
"""
with super(TestCase, self).assertRaises(exception) as cm:
function_callable(*args, **kwds)
return cm.exception


def call_has_props(call, props):
"""Check if a call has matching properties of a given props dictionary."""
Expand Down
33 changes: 0 additions & 33 deletions tests/CLI/deprecated_tests.py

This file was deleted.