Skip to content

Instantly share code, notes, and snippets.

View andrewsmedina's full-sized avatar

Andrews Medina andrewsmedina

View GitHub Profile
@andrewsmedina
andrewsmedina / gist:1091190
Created July 19, 2011 02:31
cookies in splinter
from nose.tools import assert_equals
class CookiesTest(object):
def test_create_and_access_a_cookie(self):
"should be able to create and access a cookie"
self.browser.cookies.add({'sha': 'zam'})
assert_equals(self.browser.cookies['sha'], 'zam')

Selenium with Python

Author

Baiju Muthukadan

Email

baiju.m.mail AT gmail.com

Version

0.3.2

Note

@andrewsmedina
andrewsmedina / gist:1115845
Created July 30, 2011 18:44
uuid generation
>>> from uuid import uuid4
>>> uuid4()
UUID('410e51fd-f2fe-40ea-9a67-16f1f5f5a4a7')
>>> str(uuid4())
'b3a1a5d3-d241-4c47-9281-b29808fd5716'
>>>
@andrewsmedina
andrewsmedina / gist:1116127
Created July 30, 2011 23:15
test client session
#...
#user = User.objects.all()[0]
session = self.client.session
session['user'] = user
session.save()
@andrewsmedina
andrewsmedina / gist:1116930
Created July 31, 2011 16:28
testing django model ordering
def test_response_should_be_ordered_by_date_desc(self):
'''
Response should be ordered by -date
'''
self.assertIn('-date', Response._meta.ordering)
@andrewsmedina
andrewsmedina / gist:1117151
Created July 31, 2011 19:58
group by exception and url
Error.objects.values('exception', 'url').annotate(Count('url'))
#save do model sobrescrito sem *args e **kwargs
ack "def save(.*force_insert.*)" -i --python -l
#filefield
ack 'filefield' -i --python -l
#imagefield
ack 'imagefield' -i --python -l
#formularios que usam post
@andrewsmedina
andrewsmedina / gist:1154225
Created August 18, 2011 14:54
python *args, **kwargs
>>> def teste(nome, idade):
... print nome, idade
...
>>> teste('andrews', 26)
andrews 26
>>> teste(nome='andrews', idade=26)
andrews 26
>>> lista = ['pacote', 200]
>>> teste(*lista)
pacote 200
TINYMCE_DEFAULT_CONFIG = {
'plugins': "imagelist,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,imagemanager",
'theme': "advanced",
'lang': 'pt-br',
'content_css' : "/media/_css/classes.css",
'theme_advanced_font_sizes': "10px,12px,13px,14px,16px,18px,20px",
'height': '400px',
'width': '720px',
'font_size_style_values': "10px,12px,13px,14px,16px,18px,20px",
'theme_advanced_toolbar_location': "top",
from tinymce.widgets import TinyMCE
class PostAdminForm(ModelForm):
conteudo = forms.CharField(widget=TinyMCE())
descricao = forms.CharField(widget=TinyMCE())
class Meta:
model = Post