Skip to content

Commit

Permalink
Format code using "black" formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-ns1 committed Dec 19, 2023
1 parent 4ec20e7 commit af849f6
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 72 deletions.
3 changes: 3 additions & 0 deletions ns1/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ def decorator(func):
def wrapper_func():
warnings.warn(reason, DeprecationWarning)
func()

return wrapper_func

return deprecated


from ns1.rest.rate_limiting import default_rate_limit_func
from ns1.rest.rate_limiting import rate_limit_strategy_concurrent
from ns1.rest.rate_limiting import rate_limit_strategy_solo
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Plan(resource.BaseResource):

ROOT = "account/plan"
PASSTHRU_FIELDS = ["type", "period", "notes"]

Expand Down
1 change: 0 additions & 1 deletion ns1/rest/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Acls(resource.BaseResource):

ROOT = "acls"
PASSTHRU_FIELDS = ["src_prefixes", "tsig_keys", "gss_tsig_identities"]

Expand Down
1 change: 0 additions & 1 deletion ns1/rest/apikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class APIKey(resource.BaseResource):

ROOT = "account/apikeys"
PASSTHRU_FIELDS = [
"name",
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/client_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class ClientClasses(resource.BaseResource):

ROOT = "dhcp"
CLIENT_CLASS_ROOT = "clientclass"

Expand Down
2 changes: 0 additions & 2 deletions ns1/rest/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Source(resource.BaseResource):

ROOT = "data/sources"
PASSTHRU_FIELDS = ["name", "config"]

Expand Down Expand Up @@ -76,7 +75,6 @@ def publish(self, sourceid, data, callback=None, errback=None):


class Feed(resource.BaseResource):

ROOT = "data/feeds"
PASSTHRU_FIELDS = ["name", "config"]

Expand Down
4 changes: 0 additions & 4 deletions ns1/rest/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Monitors(resource.BaseResource):

ROOT = "monitoring/jobs"
PASSTHRU_FIELDS = [
"name",
Expand Down Expand Up @@ -69,7 +68,6 @@ def delete(self, jobid, callback=None, errback=None):


class NotifyLists(resource.BaseResource):

ROOT = "lists"
PASSTHRU_FIELDS = []

Expand Down Expand Up @@ -116,7 +114,6 @@ def delete(self, nlid, callback=None, errback=None):


class JobTypes(resource.BaseResource):

ROOT = "monitoring/jobtypes"
PASSTHRU_FIELDS = []

Expand All @@ -130,7 +127,6 @@ def list(self, callback=None, errback=None):


class Regions(resource.BaseResource):

ROOT = "monitoring/regions"
PASSTHRU_FIELDS = []

Expand Down
1 change: 0 additions & 1 deletion ns1/rest/pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Pools(resource.BaseResource):

ROOT = "ipam"
ADDRESS_ROOT = "address"
POOL_ROOT = "pool"
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class Records(resource.BaseResource):

ROOT = "zones"

INT_FIELDS = ["ttl"]
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class BaseResource:

DEFAULT_TRANSPORT = "requests"

INT_FIELDS = []
Expand Down
3 changes: 1 addition & 2 deletions ns1/rest/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class Stats(resource.BaseResource):

ROOT = "stats"

def qps(
Expand Down Expand Up @@ -59,7 +58,7 @@ def usage(

return self._make_request(
"GET",
url + ('?' + urlencode(args) if args else ''),
url + ("?" + urlencode(args) if args else ""),
callback=callback,
errback=errback,
pagination_handler=stats_usage_pagination,
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Team(resource.BaseResource):

ROOT = "account/teams"
PASSTHRU_FIELDS = ["name", "ip_whitelist", "permissions"]

Expand Down
1 change: 0 additions & 1 deletion ns1/rest/transport/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class TransportBase(object):

REGISTRY = {}

def __init__(self, config, module):
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class User(resource.BaseResource):

ROOT = "account/users"
PASSTHRU_FIELDS = [
"name",
Expand Down
1 change: 0 additions & 1 deletion ns1/rest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Views(resource.BaseResource):

ROOT = "views"
INT_FIELDS = [
"preference",
Expand Down
32 changes: 5 additions & 27 deletions ns1/rest/zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ def search(
errback=errback,
)

def list_versions(
self,
zone,
callback=None,
errback=None
):
def list_versions(self, zone, callback=None, errback=None):
request = "{}/{}/versions".format(self.ROOT, zone)
return self._make_request(
"GET",
Expand All @@ -125,12 +120,7 @@ def list_versions(
errback=errback,
)

def create_version(
self,
zone,
force=False,
callback=None,
errback=None):
def create_version(self, zone, force=False, callback=None, errback=None):
request = "{}/{}/versions?force={}".format(
self.ROOT, zone, str.lower(str(force))
)
Expand All @@ -142,12 +132,7 @@ def create_version(
errback=errback,
)

def activate_version(
self,
zone,
version_id,
callback=None,
errback=None):
def activate_version(self, zone, version_id, callback=None, errback=None):
request = "{}/{}/versions/{}/activate".format(
self.ROOT, zone, str(version_id)
)
Expand All @@ -159,15 +144,8 @@ def activate_version(
errback=errback,
)

def delete_version(
self,
zone,
version_id,
callback=None,
errback=None):
request = "{}/{}/versions/{}".format(
self.ROOT, zone, str(version_id)
)
def delete_version(self, zone, version_id, callback=None, errback=None):
request = "{}/{}/versions/{}".format(self.ROOT, zone, str(version_id))
return self._make_request(
"DELETE",
request,
Expand Down
2 changes: 0 additions & 2 deletions ns1/zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def success(result, *args):
)

def __getattr__(self, item):

if not item.startswith("add_"):
raise AttributeError(item)

Expand Down Expand Up @@ -160,7 +159,6 @@ def linkRecord(
errback=None,
**kwargs
):

"""
Create a new linked record in this zone. These records use the
configuration (answers, ttl, filters, etc) from an existing record
Expand Down
41 changes: 17 additions & 24 deletions tests/unit/test_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,59 +52,52 @@ def test_rest_zone_retrieve(zones_config, zone, url):
)


@pytest.mark.parametrize("zone, url", [("test.zone", "zones/test.zone/versions")])
@pytest.mark.parametrize(
"zone, url", [("test.zone", "zones/test.zone/versions")]
)
def test_rest_zone_version_list(zones_config, zone, url):
z = ns1.rest.zones.Zones(zones_config)
z._make_request = mock.MagicMock()
z.list_versions(zone)
z._make_request.assert_called_once_with(
"GET",
url,
params={},
callback=None,
errback=None
"GET", url, params={}, callback=None, errback=None
)


@pytest.mark.parametrize("zone, url", [("test.zone", "zones/test.zone/versions?force=false")])
@pytest.mark.parametrize(
"zone, url", [("test.zone", "zones/test.zone/versions?force=false")]
)
def test_rest_zone_version_create(zones_config, zone, url):
z = ns1.rest.zones.Zones(zones_config)
z._make_request = mock.MagicMock()
z.create_version(zone)
z._make_request.assert_called_once_with(
"PUT",
url,
params={},
callback=None,
errback=None
"PUT", url, params={}, callback=None, errback=None
)


@pytest.mark.parametrize("zone, id, url", [("test.zone", 15, "zones/test.zone/versions/15/activate")])
@pytest.mark.parametrize(
"zone, id, url",
[("test.zone", 15, "zones/test.zone/versions/15/activate")],
)
def test_rest_zone_version_activate(zones_config, zone, id, url):
z = ns1.rest.zones.Zones(zones_config)
z._make_request = mock.MagicMock()
z.activate_version(zone, id)
z._make_request.assert_called_once_with(
"POST",
url,
params={},
callback=None,
errback=None
"POST", url, params={}, callback=None, errback=None
)


@pytest.mark.parametrize("zone, id, url", [("test.zone", 15, "zones/test.zone/versions/15")])
@pytest.mark.parametrize(
"zone, id, url", [("test.zone", 15, "zones/test.zone/versions/15")]
)
def test_rest_zone_version_delete(zones_config, zone, id, url):
z = ns1.rest.zones.Zones(zones_config)
z._make_request = mock.MagicMock()
z.delete_version(zone, id)
z._make_request.assert_called_once_with(
"DELETE",
url,
params={},
callback=None,
errback=None
"DELETE", url, params={}, callback=None, errback=None
)


Expand Down

0 comments on commit af849f6

Please sign in to comment.