testBase.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. class TestBase():
  2. conf = 'tests/test_pybotrc'
  3. irc_server = 'irc.zero9f9.com'
  4. def testConfExistence(self):
  5. f = open (TestBase.conf)
  6. assert f is not None
  7. def testConfman(self):
  8. import confman
  9. cm = confman.ConfManager(TestBase.conf)
  10. def testBase(self):
  11. import bot
  12. import confman
  13. assert bot.Bot(conf=confman.ConfManager(TestBase.conf), network=TestBase.irc_server) is not None, "bot is None! Check tests/test_pybotrc for reachable IRC server."
  14. # this one you might want to remove, since it connects to a hardcoded ircd
  15. def testBotSocket(self):
  16. import bot
  17. import confman
  18. b = bot.Bot(confman.ConfManager(TestBase.conf), TestBase.irc_server, True)
  19. b.worker(mock=True)
  20. assert b.s is not None
  21. # if this fails someone screwed something up
  22. def testEventMatches(self):
  23. import event
  24. e = event.Event('__.test__')
  25. assert e is not None
  26. assert e._type is not None and e._type == "__.test__"
  27. e.define(msg_definition="^test")
  28. assert e.msg_definition == "^test"
  29. assert e.matches(":hlmtre!~hlmtre@bxr.bxr.bxr PRIVMSG #bots :test") == True
  30. def testLoad(self):
  31. import bot
  32. import confman
  33. b = bot.Bot(confman.ConfManager(TestBase.conf), TestBase.irc_server, True)
  34. b.load_modules()
  35. assert len(b.loaded_modules) > 0