Skip to content

Instantly share code, notes, and snippets.

@jsmoxon
jsmoxon / gist:3716064
Created September 13, 2012 17:34
asserTrue
self.assertTrue('I am some other page content' in body.text)
@jsmoxon
jsmoxon / prerun.py
Created September 13, 2012 00:39
Simple Pre-Run Executable Example
import unittest
from selenium import webdriver
class Selenium2OnSauce(unittest.TestCase):
def setUp(self):
desired_capabilities = webdriver.DesiredCapabilities.CHROME
# desired_capabilities['version'] = ''
desired_capabilities['platform'] = 'VISTA'
desired_capabilities['name'] = 'Clicking links at jackmoxon.com on Chrome'
@jsmoxon
jsmoxon / driver_wait.py
Created September 12, 2012 23:49
driver and wait
self.driver = webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://username:API_KEY@ondemand.saucelabs.com:80/wd/hub"
)
self.driver.implicitly_wait(30)
@jsmoxon
jsmoxon / tear_down.py
Created September 12, 2012 23:38
Teardown Method
self.assertTrue('I am some other page content' in body.text)
def tearDown(self):
print "Link to your job: https://saucelabs.com/jobs/%s" % self.driver.session_id
self.driver.quit()
if __name__ == '__main__':
unittest.main()
@jsmoxon
jsmoxon / test_method.py
Created September 12, 2012 23:37
Test Method
...
self.driver.implicitly_wait(30)
def test_sauce(self):
self.driver.get('http://saucelabs.com/test/guinea-pig')
self.assertTrue("I am a page title - Sauce Labs" in self.driver.title);
self.driver.find_element_by_id('comments').send_keys('Hello! I am some example comments. I should appear in the page after you submit the form')
self.driver.find_element_by_id('submit').click()
comments = self.driver.find_element_by_id('your_comments')
@jsmoxon
jsmoxon / basic_test.py
Created September 12, 2012 23:34
Simple Python Test for use on Sauce Labs
import unittest
from selenium import webdriver
class Selenium2OnSauce(unittest.TestCase):
def setUp(self):
desired_capabilities = webdriver.DesiredCapabilities.IPHONE
desired_capabilities['version'] = '5.0'
desired_capabilities['platform'] = 'MAC'
desired_capabilities['name'] = 'Testing Selenium 2 in Python at Sauce'
@jsmoxon
jsmoxon / basic_test.py
Created September 12, 2012 23:33
Setup Method
import unittest
from selenium import webdriver
class Selenium2OnSauce(unittest.TestCase):
def setUp(self):
desired_capabilities = webdriver.DesiredCapabilities.IPHONE
desired_capabilities['version'] = '5.0'
desired_capabilities['platform'] = 'MAC'
desired_capabilities['name'] = 'Testing Selenium 2 in Python at Sauce'
@jsmoxon
jsmoxon / urls.py
Created June 9, 2012 19:16
urls.py for Django RSS Feed
from feeds import LatestPosts
urlpatterns = patterns('',
...
url(r'^latest/feed/$', LatestPosts()),
)
@jsmoxon
jsmoxon / feeds.py
Created June 9, 2012 19:11
Feeds.py for Django RSS
from django.contrib.syndication.views import Feed
from models import *
class LatestPosts(Feed):
title = "Your Blog"
link = "http://www.yourdomain.com/blog/"
description = "Latest blog posts..."
def items(self):
return Post.objects.order_by('-published_date')[:50]
@jsmoxon
jsmoxon / Negative Externalities
Created January 9, 2012 01:55
Part 2 - Hungry Academy - JSM
Milton Friedman said it best: no single person could make a pencil. To do so one would have to smelt steel to build a saw to cut a tree, produce rubber for an eraser, mine graphite, etc. And yet, someone decided it was worth all that trouble provided they could sell it for a mere $.13.
The price of a good signals the cost that the producer paid to make the good to consumers.
But what if that rubber factory produces toxic waste and dumps it into an adjacent river? If you were a fisherman down stream you’d say that pencil cost you something. It cost you the fish you could otherwise catch and sell - and you won’t see a penny of that $.13!
The pollution that kills your fish is a negative externality - a cost associated with a good that is not reflected in the price and incurred by a party that did not agree to pay it. In this case: you – a person who receives no direct benefit from pencil manufacturing – bear a cost that you did not intend to – i.e. you can’t sell fish you expected to.
Several remedies exist