launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07392
[Merge] lp:~rvb/maas/mac-address-capitalization into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/mac-address-capitalization into lp:maas with lp:~rvb/maas/edit-mac-bug-968276 as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/mac-address-capitalization/+merge/103829
This branch was inspired by jtv's comment on https://code.launchpad.net/~rvb/maas/edit-mac-bug-968276/+merge/103681. Turns out the capitalization of "MAC address" is a little bit of a mess and was written: "MAC address" (the right spelling), "MAC Address" and even sometimes "Mac address". This fairly mechanical branch fixes that by replacing all the different spelling by "MAC address" (and same for "MAC addresses").
While reading the diff, I even spotted a weird animal: "MAC Addresss" (in a comment). Fixed!
Most of the fixes are in comments. Also, the test suite passes so it gives me confidence that everything is fine but I'm still putting this branch up for review.
--
https://code.launchpad.net/~rvb/maas/mac-address-capitalization/+merge/103829
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/mac-address-capitalization into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-04-24 16:46:33 +0000
+++ src/maasserver/api.py 2012-04-27 08:22:23 +0000
@@ -470,7 +470,7 @@
@api_exported('is_registered', 'GET')
def is_registered(self, request):
- """Returns whether or not the given MAC Address is registered within
+ """Returns whether or not the given MAC address is registered within
this MAAS (and attached to a non-retired node).
:param mac_address: The mac address to be checked.
@@ -601,21 +601,21 @@
class NodeMacsHandler(BaseHandler):
"""
- Manage all the MAC Addresses linked to a Node / Create a new MAC Address
+ Manage all the MAC addresses linked to a Node / Create a new MAC address
for a Node.
"""
allowed_methods = ('GET', 'POST',)
def read(self, request, system_id):
- """Read all MAC Addresses related to a Node."""
+ """Read all MAC addresses related to a Node."""
node = Node.objects.get_node_or_404(
user=request.user, system_id=system_id, perm=NODE_PERMISSION.VIEW)
return MACAddress.objects.filter(node=node).order_by('id')
def create(self, request, system_id):
- """Create a MAC Address for a specified Node."""
+ """Create a MAC address for a specified Node."""
node = Node.objects.get_node_or_404(
user=request.user, system_id=system_id, perm=NODE_PERMISSION.EDIT)
mac = node.add_mac_address(request.data.get('mac_address', None))
@@ -627,13 +627,13 @@
class NodeMacHandler(BaseHandler):
- """Manage a MAC Address linked to a Node."""
+ """Manage a MAC address linked to a Node."""
allowed_methods = ('GET', 'DELETE')
fields = ('mac_address',)
model = MACAddress
def read(self, request, system_id, mac_address):
- """Read a MAC Address related to a Node."""
+ """Read a MAC address related to a Node."""
node = Node.objects.get_node_or_404(
user=request.user, system_id=system_id, perm=NODE_PERMISSION.VIEW)
@@ -642,7 +642,7 @@
MACAddress, node=node, mac_address=mac_address)
def delete(self, request, system_id, mac_address):
- """Delete a specific MAC Address for the specified Node."""
+ """Delete a specific MAC address for the specified Node."""
validate_mac(mac_address)
node = Node.objects.get_node_or_404(
user=request.user, system_id=system_id, perm=NODE_PERMISSION.EDIT)
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-04-27 08:22:23 +0000
+++ src/maasserver/forms.py 2012-04-27 08:22:23 +0000
@@ -217,14 +217,14 @@
def is_valid(self):
valid = super(NodeWithMACAddressesForm, self).is_valid()
- # If the number of MAC Address fields is > 1, provide a unified
+ # If the number of MAC address fields is > 1, provide a unified
# error message if the validation has failed.
reformat_mac_address_error = (
self.errors.get('mac_addresses', None) is not None and
len(self.data['mac_addresses']) > 1)
if reformat_mac_address_error:
self.errors['mac_addresses'] = (
- ['One or more MAC Addresses is invalid.'])
+ ['One or more MAC addresses is invalid.'])
return valid
def clean_mac_addresses(self):
=== modified file 'src/maasserver/models/__init__.py'
--- src/maasserver/models/__init__.py 2012-04-27 08:22:23 +0000
+++ src/maasserver/models/__init__.py 2012-04-27 08:22:23 +0000
@@ -492,9 +492,9 @@
return status_text
def add_mac_address(self, mac_address):
- """Add a new MAC Address to this `Node`.
+ """Add a new MAC address to this `Node`.
- :param mac_address: The MAC Address to be added.
+ :param mac_address: The MAC address to be added.
:type mac_address: basestring
:raises: django.core.exceptions.ValidationError_
@@ -508,9 +508,9 @@
return mac
def remove_mac_address(self, mac_address):
- """Remove a MAC Address from this `Node`.
+ """Remove a MAC address from this `Node`.
- :param mac_address: The MAC Address to be removed.
+ :param mac_address: The MAC address to be removed.
:type mac_address: str
"""
@@ -618,10 +618,10 @@
class MACAddress(CommonInfo):
- """A `MACAddress` represents a `MAC Address
+ """A `MACAddress` represents a `MAC address
<http://en.wikipedia.org/wiki/MAC_address>`_ attached to a :class:`Node`.
- :ivar mac_address: The MAC Address.
+ :ivar mac_address: The MAC address.
:ivar node: The `Node` related to this `MACAddress`.
"""
@@ -636,7 +636,7 @@
def unique_error_message(self, model_class, unique_check):
if unique_check == ('mac_address',):
- return "This MAC Address is already registered."
+ return "This MAC address is already registered."
return super(
MACAddress, self).unique_error_message(model_class, unique_check)
=== modified file 'src/maasserver/static/js/node_add.js'
--- src/maasserver/static/js/node_add.js 2012-04-23 07:56:57 +0000
+++ src/maasserver/static/js/node_add.js 2012-04-27 08:22:23 +0000
@@ -28,7 +28,7 @@
AddNodeWidget.ATTRS = {
/**
- * The number MAC Addresses fields on the form.
+ * The number MAC addresses fields on the form.
*
* @attribute nb_mac_fields
* @type integer
@@ -54,7 +54,7 @@
Y.extend(AddNodeWidget, Y.Widget, {
/**
- * Create an input field to add a MAC Address.
+ * Create an input field to add a MAC address.
*
* @method _createMacField
* @private
@@ -71,7 +71,7 @@
if (this.get('nb_mac_fields') === 1) {
var label = this.get(
'srcNode').one('label[for="id_mac_addresses"]');
- label.set('text', "Mac addresses");
+ label.set('text', "MAC addresses");
}
var add_macaddress = this._createMacField();
var add_mac_link = this.get('srcNode').one('.add-mac-form');
=== modified file 'src/maasserver/templates/maasserver/mac_confirm_delete.html'
--- src/maasserver/templates/maasserver/mac_confirm_delete.html 2012-04-27 08:22:23 +0000
+++ src/maasserver/templates/maasserver/mac_confirm_delete.html 2012-04-27 08:22:23 +0000
@@ -1,19 +1,19 @@
{% extends "maasserver/base.html" %}
{% block nav-active-settings %}active{% endblock %}
-{% block title %}Delete MAC Address: {{ mac_to_delete.mac_address }}{% endblock %}
-{% block page-title %}Delete MAC Address: {{ mac_to_delete.mac_address }}{% endblock %}
+{% block title %}Delete MAC address: {{ mac_to_delete.mac_address }}{% endblock %}
+{% block page-title %}Delete MAC address: {{ mac_to_delete.mac_address }}{% endblock %}
{% block content %}
<div class="block auto-width">
<h2>
- Are you sure you want to delete the MAC Address "{{ mac_to_delete.mac_address }}"?
+ Are you sure you want to delete the MAC address "{{ mac_to_delete.mac_address }}"?
</h2>
<p>This action is permanent and can not be undone.</p>
<p>
<form action="." method="post">
<input type="hidden" name="post" value="yes" />
- <input type="submit" value="Delete MAC Address" class="right" />
+ <input type="submit" value="Delete MAC address" class="right" />
<a href="{% url 'node-edit' mac_to_delete.node.system_id %}">Cancel</a>
</form>
</p>
=== modified file 'src/maasserver/templates/maasserver/node_add_mac.html'
--- src/maasserver/templates/maasserver/node_add_mac.html 2012-04-27 08:22:23 +0000
+++ src/maasserver/templates/maasserver/node_add_mac.html 2012-04-27 08:22:23 +0000
@@ -1,8 +1,8 @@
{% extends "maasserver/base.html" %}
{% block nav-active-settings %}active{% endblock %}
-{% block title %}Add MAC Address{% endblock %}
-{% block page-title %}Add MAC Address{% endblock %}
+{% block title %}Add MAC address{% endblock %}
+{% block page-title %}Add MAC address{% endblock %}
{% block content %}
<form action="." method="post" class="block auto-width">
@@ -11,7 +11,7 @@
{% include "maasserver/form_field.html" %}
{% endfor %}
</ul>
- <input type="submit" class="right" value="Add MAC Address" />
+ <input type="submit" class="right" value="Add MAC address" />
<a class="link-button"
href="{% url 'node-edit' node.system_id %}">Cancel</a>
</form>
=== modified file 'src/maasserver/templates/maasserver/node_edit.html'
--- src/maasserver/templates/maasserver/node_edit.html 2012-04-27 08:22:23 +0000
+++ src/maasserver/templates/maasserver/node_edit.html 2012-04-27 08:22:23 +0000
@@ -11,7 +11,7 @@
{% include "maasserver/form_field.html" %}
{% endfor %}
<li>
- <label for="id_mac_addresses">Mac addresses</label>
+ <label for="id_mac_addresses">MAC addresses</label>
{% for macaddress in node.macaddress_set.all %}
<p>
{{ macaddress }}
@@ -22,7 +22,7 @@
</a>
</p>
{% empty %}
- No MAC Address.
+ No MAC address.
{% endfor %}
</li>
<li>
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-04-26 05:44:05 +0000
+++ src/maasserver/tests/test_api.py 2012-04-27 08:22:23 +0000
@@ -313,7 +313,7 @@
self.assertEqual(httplib.BAD_REQUEST, response.status_code)
self.assertIn('application/json', response['Content-Type'])
self.assertEqual(
- ["One or more MAC Addresses is invalid."],
+ ["One or more MAC addresses is invalid."],
parsed_result['mac_addresses'])
def test_POST_invalid_architecture_returns_bad_request(self):
@@ -504,7 +504,7 @@
(response.status_code, response.content))
def test_is_registered_normalizes_mac_address(self):
- # These two non-normalized MAC Addresses are the same.
+ # These two non-normalized MAC addresses are the same.
non_normalized_mac_address = 'AA-bb-cc-dd-ee-ff'
non_normalized_mac_address2 = 'aabbccddeeff'
factory.make_mac_address(non_normalized_mac_address)
@@ -1302,7 +1302,7 @@
return node, mac1, mac2
def test_macs_GET(self):
- # The api allows for fetching the list of the MAC Addresss for a node.
+ # The api allows for fetching the list of the MAC address for a node.
node, mac1, mac2 = self.createNodeWithMacs()
response = self.client.get(
self.get_uri('nodes/%s/macs/') % node.system_id)
@@ -1316,7 +1316,7 @@
mac2.mac_address, parsed_result[1]['mac_address'])
def test_macs_GET_forbidden(self):
- # When fetching MAC Addresses, the api returns a 'Forbidden' (403)
+ # When fetching MAC addresses, the api returns a 'Forbidden' (403)
# error if the node is not visible to the logged-in user.
other_node = factory.make_node(
status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
@@ -1326,15 +1326,15 @@
self.assertEqual(httplib.FORBIDDEN, response.status_code)
def test_macs_GET_not_found(self):
- # When fetching MAC Addresses, the api returns a 'Not Found' (404)
+ # When fetching MAC addresses, the api returns a 'Not Found' (404)
# error if no node is found.
response = self.client.get(self.get_uri('nodes/invalid-id/macs/'))
self.assertEqual(httplib.NOT_FOUND, response.status_code)
def test_macs_GET_node_not_found(self):
- # When fetching a MAC Address, the api returns a 'Not Found' (404)
- # error if the MAC Address does not exist.
+ # When fetching a MAC address, the api returns a 'Not Found' (404)
+ # error if the MAC address does not exist.
node = factory.make_node()
response = self.client.get(
self.get_uri(
@@ -1343,7 +1343,7 @@
self.assertEqual(httplib.NOT_FOUND, response.status_code)
def test_macs_GET_node_forbidden(self):
- # When fetching a MAC Address, the api returns a 'Forbidden' (403)
+ # When fetching a MAC address, the api returns a 'Forbidden' (403)
# error if the node is not visible to the logged-in user.
other_node = factory.make_node(
status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
@@ -1354,8 +1354,8 @@
self.assertEqual(httplib.FORBIDDEN, response.status_code)
def test_macs_GET_node_bad_request(self):
- # When fetching a MAC Address, the api returns a 'Bad Request' (400)
- # error if the MAC Address is not valid.
+ # When fetching a MAC address, the api returns a 'Bad Request' (400)
+ # error if the MAC address is not valid.
node = factory.make_node()
response = self.client.get(
self.get_uri('nodes/%s/macs/invalid-mac/') % node.system_id)
@@ -1363,7 +1363,7 @@
self.assertEqual(400, response.status_code)
def test_macs_POST_add_mac(self):
- # The api allows to add a MAC Address to an existing node.
+ # The api allows to add a MAC address to an existing node.
node = factory.make_node(owner=self.logged_in_user)
nb_macs = MACAddress.objects.filter(node=node).count()
response = self.client.post(
@@ -1378,7 +1378,7 @@
MACAddress.objects.filter(node=node).count())
def test_macs_POST_add_mac_without_edit_perm(self):
- # Adding a MAC Address to a node requires the NODE_PERMISSION.EDIT
+ # Adding a MAC address to a node requires the NODE_PERMISSION.EDIT
# permission.
node = factory.make_node()
response = self.client.post(
@@ -1389,7 +1389,7 @@
def test_macs_POST_add_mac_invalid(self):
# A 'Bad Request' response is returned if one tries to add an invalid
- # MAC Address to a node.
+ # MAC address to a node.
node = self.createNodeWithMacs(self.logged_in_user)[0]
response = self.client.post(
self.get_uri('nodes/%s/macs/') % node.system_id,
@@ -1403,7 +1403,7 @@
parsed_result['mac_address'])
def test_macs_DELETE_mac(self):
- # The api allows to delete a MAC Address.
+ # The api allows to delete a MAC address.
node, mac1, mac2 = self.createNodeWithMacs(self.logged_in_user)
nb_macs = node.macaddress_set.count()
response = self.client.delete(
@@ -1416,7 +1416,7 @@
node.macaddress_set.count())
def test_macs_DELETE_mac_forbidden(self):
- # When deleting a MAC Address, the api returns a 'Forbidden' (403)
+ # When deleting a MAC address, the api returns a 'Forbidden' (403)
# error if the node is not visible to the logged-in user.
node, mac1, _ = self.createNodeWithMacs()
other_node = factory.make_node(
@@ -1428,8 +1428,8 @@
self.assertEqual(httplib.FORBIDDEN, response.status_code)
def test_macs_DELETE_not_found(self):
- # When deleting a MAC Address, the api returns a 'Not Found' (404)
- # error if no existing MAC Address is found.
+ # When deleting a MAC address, the api returns a 'Not Found' (404)
+ # error if no existing MAC address is found.
node = factory.make_node(owner=self.logged_in_user)
response = self.client.delete(
self.get_uri('nodes/%s/macs/%s/') % (
@@ -1438,7 +1438,7 @@
self.assertEqual(httplib.NOT_FOUND, response.status_code)
def test_macs_DELETE_forbidden(self):
- # When deleting a MAC Address, the api returns a 'Forbidden'
+ # When deleting a MAC address, the api returns a 'Forbidden'
# (403) error if the user does not have the 'edit' permission on the
# node.
node = factory.make_node(owner=self.logged_in_user)
@@ -1449,8 +1449,8 @@
self.assertEqual(httplib.NOT_FOUND, response.status_code)
def test_macs_DELETE_bad_request(self):
- # When deleting a MAC Address, the api returns a 'Bad Request' (400)
- # error if the provided MAC Address is not valid.
+ # When deleting a MAC address, the api returns a 'Bad Request' (400)
+ # error if the provided MAC address is not valid.
node = factory.make_node()
response = self.client.delete(
self.get_uri('nodes/%s/macs/%s/') % (
=== modified file 'src/maasserver/tests/test_forms.py'
--- src/maasserver/tests/test_forms.py 2012-04-27 08:22:23 +0000
+++ src/maasserver/tests/test_forms.py 2012-04-27 08:22:23 +0000
@@ -86,7 +86,7 @@
self.assertEqual(ARCHITECTURE.i386, form.cleaned_data['architecture'])
def test_NodeWithMACAddressesForm_simple_invalid(self):
- # If the form only has one (invalid) MAC Address field to validate,
+ # If the form only has one (invalid) MAC address field to validate,
# the error message in form.errors['mac_addresses'] is the
# message from the field's validation error.
form = NodeWithMACAddressesForm(
@@ -102,7 +102,7 @@
form.errors['mac_addresses'])
def test_NodeWithMACAddressesForm_multiple_invalid(self):
- # If the form has multiple MAC Address fields to validate,
+ # If the form has multiple MAC address fields to validate,
# if one or more fields are invalid, a single error message is
# present in form.errors['mac_addresses'] after validation.
form = NodeWithMACAddressesForm(
@@ -114,11 +114,11 @@
self.assertFalse(form.is_valid())
self.assertEqual(['mac_addresses'], list(form.errors))
self.assertEqual(
- ['One or more MAC Addresses is invalid.'],
+ ['One or more MAC addresses is invalid.'],
form.errors['mac_addresses'])
def test_NodeWithMACAddressesForm_empty(self):
- # Empty values in the list of MAC Addresses are simply ignored.
+ # Empty values in the list of MAC addresses are simply ignored.
form = NodeWithMACAddressesForm(
self.get_QueryDict({
'mac_addresses': ['aa:bb:cc:dd:ee:ff', ''],
@@ -592,7 +592,7 @@
form = MACAddressForm(node=node, data={'mac_address': mac})
self.assertFalse(form.is_valid())
self.assertEquals(
- {'mac_address': ['This MAC Address is already registered.']},
+ {'mac_address': ['This MAC address is already registered.']},
form._errors)
self.assertFalse(
MACAddress.objects.filter(node=node, mac_address=mac).exists())
=== modified file 'src/maasserver/tests/test_views_nodes.py'
--- src/maasserver/tests/test_views_nodes.py 2012-04-27 08:22:23 +0000
+++ src/maasserver/tests/test_views_nodes.py 2012-04-27 08:22:23 +0000
@@ -393,7 +393,7 @@
self.assertEqual(httplib.NOT_FOUND, response.status_code)
def test_node_delete_redirects_if_mac_does_not_exist(self):
- # If the MAC Address does not exist, the user is redirected
+ # If the MAC address does not exist, the user is redirected
# to the node edit page.
node = factory.make_node(owner=self.logged_in_user)
mac = factory.getRandomMACAddress()
@@ -417,7 +417,7 @@
mac_delete_link = reverse('mac-delete', args=[node.system_id, mac])
response = self.client.get(mac_delete_link)
self.assertIn(
- 'Are you sure you want to delete the MAC Address "%s"' %
+ 'Are you sure you want to delete the MAC address "%s"' %
mac.mac_address,
response.content)
@@ -471,7 +471,7 @@
response = self.client.post(mac_add_link, {'mac_address': mac})
response = self.client.get(urlparse(response['Location']).path)
self.assertEqual(
- ["MAC Address added."],
+ ["MAC address added."],
[message.message for message in response.context['messages']])
=== modified file 'src/maasserver/views/nodes.py'
--- src/maasserver/views/nodes.py 2012-04-27 08:22:23 +0000
+++ src/maasserver/views/nodes.py 2012-04-27 08:22:23 +0000
@@ -201,7 +201,7 @@
def form_valid(self, form):
res = super(MacAdd, self).form_valid(form)
- messages.info(self.request, "MAC Address added.")
+ messages.info(self.request, "MAC address added.")
return res
def get_success_url(self):
@@ -239,4 +239,4 @@
def name_object(self, obj):
"""See `HelpfulDeleteView`."""
- return "MAC Address %s" % obj.mac_address
+ return "MAC address %s" % obj.mac_address