Writing test cases for Transifex
Jul 9th, 2008 by diegobz
Last week I wrote some test cases for the new features added in Transifex. I was not used to write them, so I’ve had some challenges to win. After see some Dimitris’s test cases I could figure out how it work. Then, I’ve started to write my own test cases.
Test cases are simple to write. They help to much when we have several people working hardly in the same branch. So, people can pull/push and see if some code, that it has been coded for somebody, breaks anything.
Most of test cases has been written by Dimitris only can test pages (view) that doesn’t need identity. We had a problem with pages where an user should be logged in. Fortunately we could find out a way to solve this problem. BrowsingSession is the way!
class TestModuleTranslator(TestModule):
"""Test how module pages look to a translator."""
def test_moduleinfo_logged(self):
"""Test access to the Module Submit page"""
user = testutil.BrowsingSession()
user.goto('/login?user_name=guest&password=guest&login=Login')
user.goto(u"/module/%s" % self.testmodule)
assert 'Submit translations' in user.response
Using BrowsingSession you can browse for any page that need identity and do any test that you want. That’s simple and works fine for any situation that I’ve tested.
The Transifex’s test cases has written until now can be found here. Hopefully we’ll have more soon!