16 Commits

Author SHA1 Message Date
Jay S. Bryant
d8301e58bf Add hacking check for oslo namespace usage
We want to make sure that we don't have usage of the old
oslo.concurrency naming slipping in with new changes where
we should be using the oslo_concurrency namespace.  This change
adds a hacking check to avoid use of the deprecated namespace.
As we convert more oslo libraries to the new namespace the check
will be updated to enforce use of the new namespace.

This hacking check is based upon the same N333 hacking check
in Cinder.

Change-Id: Ibec6d09e9d313c9e723f7542cedb9da5772d3de2
2015-01-14 09:09:58 -06:00
git-harry
322126212e Fix calls to assert_called_once in unit tests
Mock has a method called assert_called_once_with to check that a mock
was called and the arguments it took were as expected. Mock does not
have a method called assert_called_once and calling it just creates a
mock bound to that name. This means that not only is nothing tested
when assert_called_once is used, the tests also don't warn about this.

This commit attempts to address this in two ways:
    - all occurrences of assert_called_once are replaced with a real
      assertion.
    - the hacking check that nova uses to guard against this has been
      copied to cinder's local hacking checks.

Fixing the assert_called_once issues also highlighted other mistakes
in certain tests which were addressed to make the tests pass.

Due to the nature of mock, this issue is also possible if a method is
misspelt or just mistakenly used and so the hacking check is only
addressing one very specific case. That said, it does appear to be a
common mistake and so is worth singling out.

Change-Id: Iedcc3f48d91f7ebd8878ccc3bca3d023503774bd
Closes-Bug: #1394544
2014-11-24 16:56:10 +00:00
Jay S. Bryant
79b6b98f21 Updated HACKING.rst so that it is accurate
We haven't been very good at enforcing putting new hacking checks
into HACKING.rst.  This change brings the file up to date.

Change-Id: I95ef533d031d333da5615ead997b54c6506c2c2a
2014-08-09 22:07:11 -05:00
Jay S. Bryant
097d3d7910 Add hacking check for use of LOG.audit
Commit 4dc37abc removes the few instances of LOG.audit that
were in Cinder.  Given that the plan is to remove LOG.audit messages
from OpenStack, I am adding this hacking check to ensure that such
messages do not sneak their way back into Cinder.

Unit tests are included with this change.

Change-Id: Icc416a68f958f60260f1c55af0d8605c95913bf1
2014-08-09 10:22:03 -05:00
Jay S. Bryant
5347439142 Improve regex for _ import hacking check
Commit 3e2b1117 added a check to make sure that the _
function was being explicitly imported so that translation would
work properly.

I have discovered that those regexes/code would not work in some cases.
Particularly if the import line imported multiple things from
gettextutils or i18n.  Also the check being used to find lines using
the _ function was not right.

This commit fixes the issues and adds appropriate tests.  It also
adds the hacking check to HACKING.rst which should have been done the
first time around.

Change-Id: I7227bb0051836e537bff2f0f97662c06452d5af6
2014-08-07 15:55:58 -05:00
Christian Berendt
5061ab9586 debug level logs should not be translated
According to the OpenStack translation policy available at
https://wiki.openstack.org/wiki/LoggingStandards debug messages
should not be translated. Like mentioned in several changes in
Nova by garyk this is to help prioritize log translation.

This patch adds a new hacking check - N319 - that ensures all
debug log messages don't have translations.

Change-Id: Id9c2715f25c8f2ea52235aba4bd1583655391584
Implements: blueprint debug-translation-removal
Closes-Bug: #1318713
2014-06-18 09:03:02 -06:00
Avishay Traeger
96420a1e26 Update HACKING.rst with regard to mock usage
Add a sentence about using mock rather than mox for unit tests.

Change-Id: If3c175d986f3ebed6d949df5c473e0cf9177ef6e
2014-01-21 18:01:02 +02:00
chadlung
ed19770844 Adding helpful URL links to README.rst and HACKING.rst
Change-Id: Id9d3606616993c50bf6ab29880efa495999b9ce4
2013-12-27 19:29:17 -06:00
Joe Gordon
20d177db37 Update URL for global HACKING document and remove duplicate section
* Related to I579e7c889f3addc2cd40bce0c584bbc70bf435e2

* Remove section on locals since its already in global hacking doc
  (http://git.openstack.org/cgit/openstack-dev/hacking/tree/doc/source/index.rst#n154)

Change-Id: I5acb06dfde6eb7f579d8d52bc31fafbdab8c726d
2013-11-11 11:39:23 -08:00
Mike Perez
3cd21880af Update OpenStack Style Commandments link
The current link in the HACKING file is broken. This references the
correct location for contributors to view.

Change-Id: I614f78fdea32025c2c5cf9599c698dde9c81ab21
2013-09-28 23:02:23 -07:00
Joe Gordon
242976b4b8 Cleanup and make HACKING.rst DRYer
Reference the OpenStack hacking guide in HACKING.rst and remove
duplicate entries.  Add placeholder section for cinder specific rules.
cinder specific rules can be created using hacking's local check
support.

Change-Id: Ia74da70363e3fe602405a440c1d2ec75052e9193
2013-07-13 09:16:23 -07:00
Sergey Vilgelm
33f6d78c3a Do not raise NEW exceptions
Raising NEW exception is bad practice, because we lose TraceBack.
So all places like:

except SomeException as e:
    raise e

should be replaced by

except SomeException:
    raise

If we are doing some other actions before reraising we should
store information about exception then do all actions and then
reraise it. This is caused by eventlet bug. It lost information
about exception if it switch threads.

fixes bug 1191730
Change-Id: Ic2be96e9f03d2ca46d060caf6f6f7f713a1d6b82
2013-06-25 17:25:07 +04:00
Mike Perez
6251df9068 Updating HACKING to disallow the use of locals()
Change-Id: I7bf2720bdb0456274dc81a73d91296dff0e3fced
2013-05-31 01:14:37 -07:00
Zhongyue Luo
b1764fdc83 Fixes 'not in' operator usage
Change-Id: Id4c83e32f6dcb4f710c5a8d8b6f130038cf07648
2013-02-04 10:33:43 +08:00
Eric Harney
b3b1d48d53 Update HACKING.rst and related changes from Nova/PEP8.
Sync up with changes made in Nova, this adds information
about line continuation (PEP8), OpenStack capitalization,
and commit messages.

Change-Id: Id6637307411bcc7a3637ac514c4ec34e26481e0d
2012-10-22 18:41:16 -04:00
Jenkins
c53d8e343e Initial fork out of Nova. 2012-05-03 10:48:26 -07:00