Monthly Archives: March 2015

Setup multiple scenarios for e2e testing on django with django-remote-scenario

When we are testing an application (blackbox), either manually or on an automated fashion, often have the need to create different sets of data, for the different scenarios of each feature we want to test (Checkout this link: That is where django-remote-scenario comes to the rescue!.

I wrote this tool, because I needed to do e2e testing for an Angular application with a Django backend. I needed to create different sets of data, so a third party application could retrieve each one of them, via REST services at will. The idea is simple, create a "scenario file" for each scenario you want to test,and django remote scenario will translate it into an URL that can be remotely call to load the data into the database, and be ready to be consume.


Install django-remote-scenario::

pip install django-remote-scenario

Then add it to an exsiting django project::


You need add django_rs urls to your project url file like this::

urlpatterns = patterns('',
url(r'^drs/', include('django_rs.urls')),

To create custom scenarios, just create a directory inside your app named "scenarios" , then add as many files as scenarios you want to implement and create a file to import them. Inside each of those files, you need to implement a main() function setting up the models you want to create for the scenario, you could create them by hand or use something like django_dynamic_fixtures.

Note: Your scenario is not limited to creating new models, you may also mock specific parts of the enviroment as well

Once everything is ready, start the server this way, this will enable the dynamic call of scenarios::

python rune2eserver initial_data.json

Note: You need to pass a initial fixture file with the barebones of your data.

It is also possible to pass a specific settings file, for testing purposes, in case you want to do the tests using a different database for example::

python rune2eserver initial_data.json --settings=demoproject.test_settings

To start using it, just go to the following url:[APPLICATION]/[SCENARIO]

after doing that the database will be populated with the data you provided in your scenario. Take into account that, everytime you call an scenario, all the other data in the database is erased, except for the one in your initial_data fixture files, wich are loaded again, and also the one you pass as a parameter when you call the command.

Inside this repository you will find a demo Django project preconfigured with a simple scenario that sets up four objects. Use it like this:

First run the server:

$ python rune2eserver initial_data.json --settings=demoproject.test_settings

Then go to your browser and setup a scenario:

You may also pass a parameter to avoid flushing the database on a specific call:

Later you could see the results on the following url::

Password management with clipperz

Clipperz is a very useful password manager, it has a lot of features and runs all the strong cryptographic algorithms in the browser. However, it is quite difficult to install in your own server because there aren't any complete guide for that.

First download the program and some utilities

$ git clone $ cd password-manager $ sudo apt-get install python-git

Edit 'clipperz/backend/php/properties/' to correct the paths:

{ "request.path": "/php/index.php", "dump.path": "/php/dump.php", "": "false" }

Build the application

$ ./scripts/build install --backends php --frontends beta

Install mysql, php and apache:

$ sudo apt-get install php5-mysql mysql-server apache2 libapache2-mod-php5

Now we have to create the database:

$ mysql -u root -p

> CREATE DATABASE clipperz; > GRANT ALL PRIVILEGES ON clipperz.* TO 'clipperz'@'localhost' IDENTIFIED BY 'clipperz';

Copy the installation and update the config with your database details

$ cp -R target/php /var/www $ vi /var/www/php/configuration.php

Go to http://clipperz_host/php/setup/index.php click on POG me up an then proceed

$ cd /var/www $ cp php/beta/index.html ./

Remove the ability to access the database via the web:

$ rm -fr setup

Guía ágil para instalación de Tryton con localización Argentina

In the following article we will let you know which tools we have used and modified in Devecoop to run the python platform consist of the Tryton client, the Tryton server and data base. We have based in the tools created by Nantic, to facilitate the installation and we also include the argentinian localization.

The result at the end of our guide we will get Tryton working, with a lange number of modules and tools included, for example:

- Trytond: Tryton server.
- Tryton: Tryton client.
- Sao: Web client.
- Proteus: Is an useful library to test and to generate test data
- Oficial modules.
- Available modules for Argentina.

Please notice that we have used SO ubuntu 12.04.

Let's start

The first step is update the index:

$ apt-get update

Then install the packages below what will need to clone the diferents modules:

$ apt-get install mercurial
$ apt-get install git

And other useful libraries:

LXML is a library for processing XML and HTML

$ sudo apt-get install libxml2-dev libxslt1-dev

LDAP is a standar protocol

$ sudo apt-get install libldap2-dev libsasl2-dev libssl-dev


$ sudo apt-get install quilt

Needed for account_invoice_ar:

Swig is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages

$ sudo apt-get install swig


$ sudo apt-get install python-M2crypto
cp -r /usr/lib/python2.7/dist-packages/M2Crypto* [dentro del virualenv]/.virtualenvs/tryton_env/lib/pythonX.X/site-packages/

Tryton uses Postgres as database engine, below you have the needed packages:

$ sudo apt-get install postgresql postgresql-contrib pgadmin3 postgresql-server-dev-all

The system packages installation is completed, now we will create the directory of the new project:

$ mkdir proyecto_tryton
$ cd proyecto_tryton

Within the new file we have to clone the following repositories, that include the argentinian localization, tasks and utils. That's means many useful commands that we will use with 'invoke'(a python library to create scripts).

$ hg clone config
$ hg clone tasks
$ hg clone utils

Needed for account_invoice_ar:

hg clone
cp -r pyafipws  [dentro del virtualenv]/.virtualenvs/tryton_env/lib/pythonX.X/site-packages

With the command 'invoke -l' all the available commands will be displayed.

Many of the repositories that we have cloned needs some dependencies which we need to download whith the command 'pip' within independent enviroment that we create thanks virtualenvwrapper:

$ sudo apt-get install virtualenvwrapper
# Close and open the terminal
$ sudo apt-get install python-dev
$ mkvirtualenv nombre_del_entorno

Probably we have an old 'pip' version, thar can couse problems during the instalation so before let's update 'pip':

$ pip install pip -U
$ pip install -r tasks/requirements.txt
$ pip install -r config/requirements.txt

Then we have to create a file call 'local.cfg' en the main directory, which will be have a simbolic link from 'config/local.cfg':

$ touch local.cfg

Right now we are able to execute the 'bs' that will clone all the modules specifyed within 'project/config/':

$ invoke clone --config config/base.cfg
$ invoke clone --config config/core.cfg
$ invoke clone --config config/tryton-ar.cfg
$ invoke bs.create_symlinks

The following text must be copied in 'trytond.cong', this will be the server configuration (user and password are examples):

#This file is part of Tryton.  The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.

# This is the hostname used when generating tryton URI
#hostname =

# Activate the json-rpc protocol
jsonrpc = *:8000
#ssl_jsonrpc = False

# Configure the path of json-rpc data
#jsondata_path = /var/www/localhost/tryton

# Activate the xml-rpc protocol
#xmlrpc = *:8069
#ssl_xmlrpc = False

# Activate the webdav protocol
#webdav = *:8080
#ssl_webdav = False

# Configure the database type
# allowed values are postgresql, sqlite, mysql
db_type = postgresql

# Configure the database connection
## Note: Only databases owned by db_user will be displayed in the connection dialog
## of the Tryton client. db_user must have create permission for new databases
## to be able to use automatic database creation with the Tryton client.
db_host = localhost
db_port = 5432
db_user = tryton
db_password = tryton
#db_minconn = 1
#db_maxconn = 64

# Configure the postgresql path for the executable
#pg_path = None

# Configure the Tryton server password
admin_passwd = admin

timezone = America/Argentina/Buenos_Aires

# Configure the path of the files for the pid and the logs
#pidfile = False
#logfile = False

#privatekey = server.pem
#certificate = server.pem

# Configure the SMTP connection
#smtp_server = localhost
#smtp_port = 25
#smtp_ssl = False
#smtp_tls = False
#smtp_password = False
#smtp_user = False

# Configure the path to store attachments and sqlite database
data_path = /var/lib/tryton

# Allow to run more than one instance of trytond
#multi_server = False

# Configure the session timeout (inactivity of the client in sec)
#session_timeout = 600

# Enable psyco module
# Need to have psyco installed
#psyco = False

# Enable auto-reload of modules if changed
#auto_reload = True

# Prevent database listing
#prevent_dblist = False

# Enable cron
# cron = True

# unoconv connection
#unoconv = pipe,name=trytond;urp;StarOffice.ComponentContext

# Number of retries on database operational error
# retry = 5

Almost finished we have to create the user for the data base:

sudo su postgres
createuser --pwprompt --superuser tryton

To check the access of the data base, open the archive '/etc/postgresql/9.1/main/pg_hba.conf' and check out if there is a line like this:

local    all    all    md5

Else add a new one

Now we are prepared to run the server:

./ start

This command will show us in real time the logs. Also allows you to stop the server, restarting or specify the data base and another feathures.


./ stop
./ krestart

The Nantic guide is