steps.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from lettuce import *
  2. import subprocess
  3. import os.path
  4. import shutil
  5. copylist = [
  6. ["configurations/example.org.config.orig", "configurations/example.org.config"]
  7. ]
  8. @before.each_scenario
  9. def initialize(feature):
  10. # just make sure our cleanup won't fail if we never did
  11. # run the bind10 instance
  12. world.bind10 = None
  13. world.bind10_output = []
  14. world.last_query_result = None
  15. # Some tests can modify the settings. If the tests fail half-way, or
  16. # don't clean up, this can leave configurations or data in a bad state,
  17. # so we copy them from originals before each scenario
  18. for item in copylist:
  19. shutil.copy(item[0], item[1])
  20. @after.each_scenario
  21. def cleanup(feature):
  22. world.shutdown_server()
  23. world.bind10_output = []
  24. @step(u'Given I have no database')
  25. def given_i_have_no_database(step):
  26. if os.path.exists("test.db"):
  27. os.remove("test.db")
  28. @step(u'I should see a database file')
  29. def i_should_see_a_database_file(step):
  30. assert os.path.exists("test.db")
  31. os.remove("test.db")