Django manage.py custom command for functional testing.
Fisrtly, the command starts the django sever via python manage.py runserver
and secondly, it runs some Selenium tests.
Use:
import Tweet | |
import simplejson | |
import urllib2 | |
def read_tweets(user, num_tweets): | |
tweets = [] | |
url = "http://api.twitter.com/1/statuses/user_timeline.json?\ | |
screen_name=%s&count=%s&include_rts=true" % (user, num_tweets) | |
file = urllib2.urlopen(url) |
;;to-line short-cut key | |
(global-set-key "\C-l" 'goto-line) | |
;;M-g-g does the same | |
;; Wheel mouse + Control change buffer we are looking at | |
(defun next-buffer () | |
"Go to the buffer which is at the end of the buffer-list. | |
This is the symmetric of burry-buffer." | |
(interactive) | |
(switch-to-buffer (nth (- (length (buffer-list)) 1) (buffer-list)))) |
# simple form usage in view | |
def my_view(request, template_name='home.html'): | |
# sticks in a POST or renders an empty form | |
form = MyForm(request.POST or None) | |
if form.is_valid(): | |
do_something() | |
return redirect('/') | |
return render_to_response(template_name, {'form':form}) | |
# form with files |
from django.db import models | |
class M1(models.Model): | |
title = models.CharField(max_length=100) | |
img1 = models.ImageField(upload_to="static/") | |
def __unicode__(self): | |
return self.title |
# -*- coding: utf-8 -*- | |
#Copyright (C) 2013 Seán Hayes | |
import my_project.settings as dj_settings | |
from fabric.api import local, run, sudo, env, prompt, settings, cd, parallel, execute | |
from fabric.contrib.files import exists | |
from fabric.decorators import hosts, roles, runs_once | |
import json | |
import logging | |
import os |
from subprocess import Popen, PIPE | |
from os import environ | |
def source(script, update=True, clean=True): | |
""" | |
Source variables from a shell script | |
import them in the environment (if update==True) | |
and report only the script variables (if clean==True) | |
""" |