June 28, 2010 0

Introducing: Picka

By Anthony in Python, QA, Selenium, Test Automation, Testing

If you need to create massive amounts of randomized testing data, check out my module: Picka.

It runs harmoniously with Selenium, HTTPlib, Mechanism and more. When you combine the two, it allows you to create an infinite number of real-data driven tests – in mere moments.

Loaded with real user information, such as names, cities, states, dates, phone numbers and more – Picka makes data generation a breeze and your selenium tests much more comprehensive.

picka + MySQL example:

#!/usr/bin/env python
import MySQLdb, unittest, picka

class Connector(unittest.TestCase):
    def setUp(self):
        self.conn = MySQLdb.connect (host = "127.0.0.1",
                                user = "root",
                                db = "users")
        self.cursor = self.conn.cursor()

    def tearDown(self):
        self.cursor.close()
        self.conn.close()

class Tests(Connector):
    def test_get_flagged_comments(self):
        for x in xrange(50):
            first = picka.male_name()
            last = picka.last_name()
            p_age = picka.age()
            self.cursor.execute(
                "insert into user_data (first_name, last_name, age) VALUES ('%s', '%s', '%s')"
                 % (first, last, p_age)
                 )

unittest.main()

picka + Selenium example:

from selenium import selenium
import unittest, picka
SERVER_SETUP = ['localhost', 5556, '*firefox', 'http://google.com/']

class TestCase(unittest.TestCase):
    def setUp(self):
	self.selenium = selenium(*SERVER_SETUP)
        self.selenium.start()

    def tearDown(self):
        self.selenium.stop()

    def test_google_box(self):
        """test_google_box"""
        self.selenium.open("/")
        self.selenium.type("q", picka.male_name())

if __name__ == "__main__":
    unittest.main()