Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD with Python and App Engine

TDD with Python and App Engine

An easy way to test your App Engine Python applications

rbanffy

June 26, 2014
Tweet

More Decks by rbanffy

Other Decks in Programming

Transcript

  1. Show of hands • Who already uses App Engine with

    Python? • Who does TDD with App Engine and Python? • Who writes tests?
  2. What is Google App Engine • A PaaS - platform

    as a service • Specific APIs and libraries ◦ but can run Django, Flask etc adapted apps • You don't worry about the server • Google's team manages them for you • A local development environment • Deployment using the SDK (or git - for Java)
  3. What else is in Google App Engine • Automagic spin-up

    and spin-down of servers • Pay-as-you-go • Datastore (NoSQL) + Google Cloud SQL • Queues - for asynchronous tasks • NDB - asynchronous data access (and more) • Authentication • A framework that encourages good practices
  4. More? • A management interface • You can keep multiple

    versions deployed ◦ And split traffic between them • A brand-new management interface ◦ Integrated with the other cloud products family
  5. What we had before? • GAEUnit ◦ Deploys testing code

    to production ◦ Does it still work? • SDK testbed ◦ Batteries not included • NoseGAE, pytest-gae ◦ Some batteries included • ?
  6. Why build another one? • Include more batteries • Being

    opinionated can be good ◦ Conventions over configuration helps newcomers • Some things are missing from the vanilla SDK ◦ Examples ◦ The way Django uses its fixtures is amazing
  7. Why build another one? (continued) • Virtualenvs are cool ◦

    To break the system Python is always painful ◦ Built-in Python may not be an option • If it's hard to test, people won't ◦ Laziness is one of the virtues of a programmer (even if, in this case, it may not be) • A little bit of support goes a long way
  8. What was done? • A skeleton project (on GitHub) •

    Creates a virtualenv • Runs sanity tests • Loads data from a JSON file • Assemble everything with a Makefile • Tests do not rely on the development server • You can run ipdb (in your tests)!
  9. How do you use it? Demo 1. git clone ◦

    [email protected]:rbanffy/testable_appengine.git 2. make venv 3. nosetests (or py.test)
  10. O que falta fazer • Importar hierarquias de objetos para

    testes • Tornar mais fácil usar em projetos já em andamento ◦ Sobretudo manter o maquinário atualizado ◦ Se bem que isso pode nem ser importante • Precisamos de mais usuários ◦ Que dêem mais palpites