Skip to content

Instantly share code, notes, and snippets.

@hassek
hassek / gist:4080169
Created November 15, 2012 18:05
Get rabbit enqueued tasks and if rabbit is up
def get_rabbit_status():
try:
conn = BrokerConnection(
userid=settings.BROKER_USER,
password=settings.BROKER_PASSWORD,
hostname=settings.BROKER_HOST,
port=settings.BROKER_PORT,
virtual_host=settings.BROKER_VHOST
)
conn.connect()
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/share/npm/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/Cellar/python26/2.6.7/bin:/usr/local/Cellar/python/2.7.3/bin:/usr/local/share/python:$PATH
export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil:/usr/local/Cellar/xapian/1.2.7/bin:/usr/local/Cellar/readline/6.2.2/:
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/share/npm/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil:/usr/local/Cellar/xapian/1.2.7/bin:/usr/local/Cellar/readline/6.2.2/:
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
set nobackup
set nowritebackup
"make the yank use the system clipboard
"set clipboard=unnamed
set tabstop=2 softtabstop=2 shiftwidth=2 textwidth=0
au BufRead,BufNewFile *.html set filetype=htmldjango
set tags+=./tags;$HOME
python << endpython
def run_current_test(level='test', on_terminal=False):
import vim
command = "./manage.py test %"
cb = vim.current.buffer
cw = vim.current.window
original_position = vim.current.window.cursor
@hassek
hassek / Testing.md
Created March 14, 2018 16:50
Testing

Automated testing

Fixtures vs Factories

  • Anything that may be modified is not a good choice for fixtures but for factories instead
  • Fixtures hide the testing logic, don't use it for building use cases, instead use it for easing the testing process.
  • Fixtures still has some use cases to ease big data representations and objects that should never change (emails, user metrics, etc).

Saving vs not saving in the DB

I like to save everything on the DB until it becomes a problem, this avoids a