Skip to content
Draft
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
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:

jobs:
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.6"
python-version: "3.8"

- name: Install dependencies
run: |
Expand All @@ -29,12 +29,10 @@ jobs:
tox -e lint

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand All @@ -43,7 +41,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
2 changes: 1 addition & 1 deletion integrate/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Integration tests for `maas.client`."""

from collections import Mapping
from collections.abc import Mapping
from datetime import datetime
from http import HTTPStatus
import io
Expand Down
10 changes: 6 additions & 4 deletions maas/client/bones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ def __init__(self, request, response, content, call):
desc = "%s -> %s (%s)" % (
desc_for_request,
desc_for_response,
desc_for_content
if len(desc_for_content) <= 50
else (desc_for_content[:49] + "…"),
(
desc_for_content
if len(desc_for_content) <= 50
else (desc_for_content[:49] + "…")
),
)
super(CallError, self).__init__(desc)
self.request = request
Expand Down Expand Up @@ -460,7 +462,7 @@ async def dispatch(self, uri, body, headers):
library.
"""
insecure = self.action.handler.session.insecure
connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
connector = aiohttp.TCPConnector(ssl=(not insecure))
session = aiohttp.ClientSession(connector=connector)
async with session:
response = await session.request(
Expand Down
6 changes: 3 additions & 3 deletions maas/client/bones/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def fetch_api_description(
):
"""Fetch the API description from the remote MAAS instance."""
url_describe = urljoin(_ensure_url_string(url), "describe/")
connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
connector = aiohttp.TCPConnector(ssl=(not insecure))
session = aiohttp.ClientSession(connector=connector)
async with session, session.get(url_describe) as response:
if response.status != HTTPStatus.OK:
Expand Down Expand Up @@ -270,11 +270,11 @@ def check_response_is_okay(response):
if response.status != HTTPStatus.OK:
raise RemoteError(
"{0} -> {1.status} {1.reason}".format(
response.url_obj.human_repr(), response
response.url.human_repr(), response
)
)

connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
connector = aiohttp.TCPConnector(ssl=(not insecure))
session = aiohttp.ClientSession(connector=connector)
async with session:
# Check that this server supports `authenticate-api`.
Expand Down
2 changes: 1 addition & 1 deletion maas/client/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Custom errors for libmaas """
"""Custom errors for libmaas"""

__all__ = ["MAASException", "OperationNotAllowed"]

Expand Down
4 changes: 2 additions & 2 deletions maas/client/flesh/tests/test_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_returns_table_with_controllers(self):
output = yaml.safe_load(
cmd.execute(origin, options, target=tabular.RenderTarget.yaml)
)
self.assertEquals(
self.assertEqual(
[
{"name": "hostname", "title": "Hostname"},
{"name": "node_type", "title": "Type"},
Expand All @@ -93,7 +93,7 @@ def test_returns_table_with_controllers(self):
}
for controller in racks + regions
}
self.assertEquals(
self.assertEqual(
sorted(controller_output.values(), key=itemgetter("hostname")),
output["data"],
)
Expand Down
4 changes: 2 additions & 2 deletions maas/client/flesh/tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_returns_table_with_devices(self):
output = yaml.safe_load(
cmd.execute(origin, options, target=tabular.RenderTarget.yaml)
)
self.assertEquals(
self.assertEqual(
[
{"name": "hostname", "title": "Hostname"},
{"name": "owner", "title": "Owner"},
Expand All @@ -76,7 +76,7 @@ def test_returns_table_with_devices(self):
],
key=itemgetter("hostname"),
)
self.assertEquals(devices_output, output["data"])
self.assertEqual(devices_output, output["data"])

def test_calls_handler_with_hostnames(self):
origin = make_origin()
Expand Down
4 changes: 2 additions & 2 deletions maas/client/flesh/tests/test_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_returns_table_with_machines(self):
output = yaml.safe_load(
cmd.execute(origin, options, target=tabular.RenderTarget.yaml)
)
self.assertEquals(
self.assertEqual(
[
{"name": "hostname", "title": "Hostname"},
{"name": "power", "title": "Power"},
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_returns_table_with_machines(self):
],
key=itemgetter("hostname"),
)
self.assertEquals(machines_output, output["data"])
self.assertEqual(machines_output, output["data"])

def test_calls_handler_with_hostnames(self):
origin = make_origin()
Expand Down
4 changes: 2 additions & 2 deletions maas/client/flesh/tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_returns_table_with_nodes(self):
output = yaml.safe_load(
cmd.execute(origin, options, target=tabular.RenderTarget.yaml)
)
self.assertEquals(
self.assertEqual(
[
{"name": "hostname", "title": "Hostname"},
{"name": "node_type", "title": "Type"},
Expand All @@ -65,7 +65,7 @@ def test_returns_table_with_nodes(self):
],
key=itemgetter("hostname"),
)
self.assertEquals(nodes_output, output["data"])
self.assertEqual(nodes_output, output["data"])

def test_calls_handler_with_hostnames(self):
origin = make_origin()
Expand Down
2 changes: 1 addition & 1 deletion maas/client/utils/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,4 @@ class TestRemoveNone(TestCase):

def test_removes_all_None_values(self):
data = {"None": None, "another_None": None, "keep": "value"}
self.assertEquals({"keep": "value"}, utils.remove_None(data))
self.assertEqual({"keep": "value"}, utils.remove_None(data))
8 changes: 4 additions & 4 deletions maas/client/utils/tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ class TestCalculateDictDiff(TestCase):
def test_calcs_no_difference(self):
orig_data = {"key1": "value1", "key2": "value2"}
new_data = copy.deepcopy(orig_data)
self.assertEquals({}, calculate_dict_diff(orig_data, new_data))
self.assertEqual({}, calculate_dict_diff(orig_data, new_data))

def test_calcs_changed_value(self):
orig_data = {"key1": "value1", "key2": "value2"}
new_data = copy.deepcopy(orig_data)
new_data["key2"] = "new_value"
self.assertEquals(
self.assertEqual(
{"key2": "new_value"}, calculate_dict_diff(orig_data, new_data)
)

def test_calcs_deleted_value(self):
orig_data = {"key1": "value1", "key2": "value2"}
new_data = copy.deepcopy(orig_data)
del new_data["key2"]
self.assertEquals({"key2": ""}, calculate_dict_diff(orig_data, new_data))
self.assertEqual({"key2": ""}, calculate_dict_diff(orig_data, new_data))

def test_calcs_changes_and_deleted(self):
orig_data = {"key1": "value1", "key2": "value2"}
new_data = copy.deepcopy(orig_data)
new_data["key1"] = "new_value"
del new_data["key2"]
self.assertEquals(
self.assertEqual(
{"key1": "new_value", "key2": ""}, calculate_dict_diff(orig_data, new_data)
)
2 changes: 1 addition & 1 deletion maas/client/viscera/boot_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async def _upload_chunks(
uploaded_size = 0

insecure = cls._handler.session.insecure
connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
connector = aiohttp.TCPConnector(ssl=(not insecure))
session = aiohttp.ClientSession(connector=connector)

async with session:
Expand Down
2 changes: 1 addition & 1 deletion maas/client/viscera/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Testing framework for maas.client.viscera """
"""Testing framework for maas.client.viscera"""

__all__ = ["bind"]

Expand Down
16 changes: 8 additions & 8 deletions maas/client/viscera/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def test__can_access_pk_attributes_when_unloaded(self):
object_pk = randint(0, 20)
object_a = object_type(object_pk)
self.assertFalse(object_a.loaded)
self.assertEquals(object_pk, object_a.pk)
self.assertEqual(object_pk, object_a.pk)

def test__can_access_alt_pk_attributes_when_unloaded(self):
object_type = type(
Expand All @@ -495,7 +495,7 @@ def test__can_access_alt_pk_attributes_when_unloaded(self):
object_alt_pk = randint(0, 20)
object_a = object_type({"alt_pk_d": object_alt_pk, "__incomplete__": True})
self.assertFalse(object_a.loaded)
self.assertEquals(object_alt_pk, object_a.alt_pk)
self.assertEqual(object_alt_pk, object_a.alt_pk)

def test__can_access_attributes_when_loaded(self):
object_type = type(
Expand All @@ -507,7 +507,7 @@ def test__can_access_attributes_when_loaded(self):
object_name = make_name("name")
object_a = object_type({"pk_d": object_pk, "name": object_name})
self.assertTrue(object_a.loaded)
self.assertEquals(object_name, object_a.name)
self.assertEqual(object_name, object_a.name)

def test__equal_when_data_matches(self):
data = {"key": make_name("value")}
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def test__init__requires_str_or_Object_class(self):
ObjectFieldRelatedSet("name", ObjectSet)

def test_datum_to_value_returns_empty_list_on_None(self):
self.assertEquals(
self.assertEqual(
ObjectFieldRelatedSet("name", "class").datum_to_value(object(), None), []
)

Expand All @@ -1232,7 +1232,7 @@ def test_datum_to_value_converts_to_set_of_bound_class(self):
field = ObjectFieldRelatedSet("related_ids", "RelObjectSet")
rel_ids = range(5)
rel_object_set = field.datum_to_value(instance, rel_ids)
self.assertEquals(5, len(rel_object_set))
self.assertEqual(5, len(rel_object_set))
self.assertIsInstance(rel_object_set[0], rel_object_type)
self.assertFalse(rel_object_set[0].loaded)
self.assertThat(
Expand All @@ -1253,7 +1253,7 @@ def test_datum_to_value_uses_reverse_name(self):
field = ObjectFieldRelatedSet("related_ids", "RelObjectSet", reverse="reverse")
rel_ids = range(5)
rel_object_set = field.datum_to_value(instance, rel_ids)
self.assertEquals(5, len(rel_object_set))
self.assertEqual(5, len(rel_object_set))
self.assertIsInstance(rel_object_set[0], rel_object_type)
self.assertFalse(rel_object_set[0].loaded)
self.assertThat(
Expand All @@ -1273,7 +1273,7 @@ def test_datum_to_value_doesnt_include_reverse(self):
field = ObjectFieldRelatedSet("related_ids", "RelObjectSet", reverse=None)
rel_ids = range(5)
rel_object_set = field.datum_to_value(instance, rel_ids)
self.assertEquals(5, len(rel_object_set))
self.assertEqual(5, len(rel_object_set))
self.assertIsInstance(rel_object_set[0], rel_object_type)
self.assertFalse(rel_object_set[0].loaded)
self.assertThat(rel_object_set[0]._data, Equals({"pk_d": rel_ids[0]}))
Expand All @@ -1297,7 +1297,7 @@ def test_datum_to_value_wraps_managed_create(self):
rel_ids = range(5)
rel_object_set = field.datum_to_value(instance, rel_ids)
rel_object_set.create()
self.assertEquals(
self.assertEqual(
"RelObjectSet.Managed#InstObject", type(rel_object_set).__name__
)
self.assertThat(create_mock.call_args_list, Equals([call(instance)]))
Expand Down
8 changes: 4 additions & 4 deletions maas/client/viscera/tests/test_bcache_cache_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test__read_bad_node_type(self):
error = self.assertRaises(
TypeError, BcacheCacheSets.read, random.randint(0, 100)
)
self.assertEquals("node must be a Node or str, not int", str(error))
self.assertEqual("node must be a Node or str, not int", str(error))

def test__read_with_system_id(self):
BcacheCacheSets = make_origin().BcacheCacheSets
Expand Down Expand Up @@ -87,7 +87,7 @@ def test__create_bad_node_type(self):
random.randint(0, 100),
origin.BlockDevice({}),
)
self.assertEquals("node must be a Node or str, not int", str(error))
self.assertEqual("node must be a Node or str, not int", str(error))

def test__create_bad_cache_device_type(self):
BcacheCacheSets = make_origin().BcacheCacheSets
Expand All @@ -97,7 +97,7 @@ def test__create_bad_cache_device_type(self):
make_string_without_spaces(),
random.randint(0, 100),
)
self.assertEquals(
self.assertEqual(
"cache_device must be a BlockDevice or Partition, not int", str(error)
)

Expand Down Expand Up @@ -141,7 +141,7 @@ def test__read_bad_node_type(self):
random.randint(0, 100),
random.randint(0, 100),
)
self.assertEquals("node must be a Node or str, not int", str(error))
self.assertEqual("node must be a Node or str, not int", str(error))

def test__read_with_system_id(self):
BcacheCacheSet = make_origin().BcacheCacheSet
Expand Down
12 changes: 6 additions & 6 deletions maas/client/viscera/tests/test_bcaches.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test__get_by_name(self):
def test__read_bad_node_type(self):
Bcaches = make_origin().Bcaches
error = self.assertRaises(TypeError, Bcaches.read, random.randint(0, 100))
self.assertEquals("node must be a Node or str, not int", str(error))
self.assertEqual("node must be a Node or str, not int", str(error))

def test__read_with_system_id(self):
Bcaches = make_origin().Bcaches
Expand Down Expand Up @@ -158,7 +158,7 @@ def test__create_bad_node_type(self):
random.randint(0, 100),
CacheMode.WRITETHROUGH,
)
self.assertEquals("node must be a Node or str, not int", str(error))
self.assertEqual("node must be a Node or str, not int", str(error))

def test__create_bad_cache_device_type(self):
Bcaches = make_origin().Bcaches
Expand All @@ -171,7 +171,7 @@ def test__create_bad_cache_device_type(self):
random.randint(0, 100),
CacheMode.WRITETHROUGH,
)
self.assertEquals(
self.assertEqual(
"backing_device must be a BlockDevice or Partition, not int", str(error)
)

Expand All @@ -187,7 +187,7 @@ def test__create_bad_cache_set_type(self):
make_string_without_spaces(),
CacheMode.WRITETHROUGH,
)
self.assertEquals(
self.assertEqual(
"cache_set must be a BcacheCacheSet or int, not str", str(error)
)

Expand All @@ -203,7 +203,7 @@ def test__create_bad_cache_mode_type(self):
random.randint(0, 100),
"writethrough",
)
self.assertEquals("cache_mode must be a CacheMode, not str", str(error))
self.assertEqual("cache_mode must be a CacheMode, not str", str(error))

def test__create_with_block_device(self):
origin = make_origin()
Expand Down Expand Up @@ -257,7 +257,7 @@ def test__read_bad_node_type(self):
error = self.assertRaises(
TypeError, Bcache.read, random.randint(0, 100), random.randint(0, 100)
)
self.assertEquals("node must be a Node or str, not int", str(error))
self.assertEqual("node must be a Node or str, not int", str(error))

def test__read_with_system_id(self):
Bcache = make_origin().Bcache
Expand Down
Loading
Loading