Check for required fields on ports

Currently the API on ports does not check for any required fields,
this patch add such verifications + tests.

Change-Id: I4a2003c3a5ab0a0b31742fcac119fbe20929f636
Partial-Bug: #1223847
Add tests for api/utils.py

Currently the functions on api/utils.py is not being directly/well tested,
this patch add tests for those functions. This patch also replaces the
current regex to test the patches with a DRYer one.

Change-Id: Ibda84bd759e2a96c76d06465c6d0740d4ddea263
Merge "Check for required fields on ports"
Merge "Add tests for api/utils.py"