Introduction to patching in Python

If you want to use it in a version earlier than python3.3, you need yo install it:

sudo pip install mock

Simple example

Code to test:

import time
def do_something():
    if time.sleep(100):
        print 'ok'
    else:
        print 'ko'

Actual test:

from mock import patch
@patch('time.sleep')
def test_do_something1(mock_sleep):
    mock_sleep.return_value = True
    do_something()

@patch('time.sleep')
def test_do_something2(mock_sleep):
    mock_sleep.return_value = False
    do_something()

Results:

>>> test_do_something1()
ok
>>> test_do_something2()
ko

Source:

Port in use

To find which application is using a specific port, do:

lsof -i <port-number>

Or list ports with associated processes in use:

netstat -putln

Logs

The configuration and especially right permissions will be done in /etc/rsyslog.conf

Bitmask is going to be used so use this doc http://www.cyberciti.biz/faq/unix-linux-bsd-chmod-numeric-permissions-notation-command/

It will be taken into account for the new log files only when we reload rsylog with this commend:

/etc/init.d/rsyslog reload

The old files are still on the old configuration. So, you need to change the right access directly for them with chown and chmod.

Example for vagrant user:

root@openerp-development:/var/log/openerp# chown vagrant:vagrant /var/log/openerp/ -R
root@openerp-development:/var/log/openerp# chmod a+r /var/log/openerp/ -R

Source: http://www.rsyslog.com/

Agile testing

The best book I ever read about testing and best practices in an Agile project is: Agile Testing: A Practical Guide for Testers and Agile Teams (Addison-Wesley Signature)

The main idea of Agility is constantly giving and receiving feedback in order to keep improving the process and the output of the project.

Testing quadrant