Thanks to everyone who read this and is looking for a better way. I think unit tests are definately the simpler approach.
So according to the docs you simply need to create a file tests.py parallel to models.py and put tests in there.
from django.test import TestCase
from perforce.models import P4User, P4Client
class ModelTests(TestCase):
def setUp(self):
self.p4 = P4.P4()
self.p4.connect()
def test_BasicP4(self):
"""
Make sure we are running 2009.1 == 65
"""
self.failUnlessEqual(self.p4.api_level, 65)
def test_P4User_get_or_retrieve(self):
"""
This will simply verify we can get a user and push it into the model
"""
user = self.p4.run(("users"))[0]
dbuser = P4User.objects.get_or_retrieve(user.get('User'))
# Did it get loaded into the db?
self.assertEqual(dbuser[1], True)
# Do it again but hey it already exists..
dbuser = P4User.objects.get_or_retrieve(user.get('User'))
# Did it get loaded into the db?
self.assertEqual(dbuser[1], False)
# Verify one field of the data matches
dbuser = dbuser[0]
self.assertEqual(dbuser.email, user.get("Email"))
Now you can simply fire up the terminal and do python manage.py test and that will run the tests but again that's a pretty limited view and still requires you to swap in/out of programs.. So here is how you do this directly from Textmate using ⌘R.
Add an import line at the top and a few line at the bottom.
from django.test.simple import run_tests
#
# Unit tests from above
#
if __name__ == '__main__':
run_tests(None, verbosity=1, interactive=False)
And now ⌘R will work directly from TextMate.