Skip to content

Instantly share code, notes, and snippets.

View bulkan's full-sized avatar
🇯🇵

Savun Bulkan Evcimen bulkan

🇯🇵
View GitHub Profile
@bulkan
bulkan / gist:3712331
Created September 13, 2012 06:25
CommonLibrary.py
from robot.libraries.OperatingSystem import OperatingSystem
from robot.libraries.BuiltIn import BuiltIn
class CommonLibrary(object):
''' Common keywords that can be used by any test case'''
def __init__(self):
self.oslib = OperatingSystem()
self.builtin = BuiltIn()
@bulkan
bulkan / gist:3606776
Created September 3, 2012 04:50
rq job attributes
job = Job.fetch(job_id)
job.my_attr = ['one', 'two']
job.save()
# re-fetch job
job = Job.fetch(job_id)
print type(job.my_attr)
<type 'str'>
@bulkan
bulkan / gist:2873524
Created June 5, 2012 08:08
capture unittest output
import sys
import unittest
import StringIO
class DumbestTest(unittest.TestCase):
def test_dumber(self):
self.assertEqual(True, True)
if __name__ == '__main__':
[
{
'end_time': '2012-05-07T07: 00: 00+0000',
'value': 79
},
{
'end_time': '2012-05-08T07: 00: 00+0000',
'value': 121
},
{
import subprocess
class MyOwnKeywords(object):
def run_cmd(self, cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = p.communicate()[0]
if p.wait() != 0:
print "*WARN* %s failed" %cmd
return output
@bulkan
bulkan / qc.py
Created May 9, 2011 23:46
Export test cases in QC using Python
import win32com, win32com.client
import HTMLParser
class MLStripper(HTMLParser.HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, d):
import httplib2
import json
h = httplib2.Http()
h.add_credentials('user1', 'user1')
json_str = json.dumps({'name':"joe blows"})
response, content = h.request("http://example.com/rest", method="POST", body=json_str, headers={'content-type':'application/json'})
{% if tweets %}
<div class='latest' style='display:none;'>
{% for tweet in tweets %}
<div>
<h1><a href="http://twitter.com/{{ tweet.username }}/status/{{ tweet.id }}" class="more">{{ tweet.username }}</a> </h1>
<div class="entry">
<p>
<img align='left' height=45 width=48 src="{{ tweet.profile_image_url }}"></img>
<span> {{ tweet.text }}</span>
</p>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Queshuns</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
function refreshTweets() {
$.getJSON('/latest', {since: window.latestTweet, nt:(new Date()).getTime()},
function(data) {
import time
import os
import cherrypy
import jinja2
from filter_daemon import *
try:
import json