You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
2.6 KiB

  1. # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. #
  3. # MIT License (MIT)
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #
  22. from __future__ import unicode_literals
  23. """
  24. test with erpnext
  25. """
  26. import unittest, sys
  27. sys.path.append('lib/py')
  28. import webnotes
  29. webnotes.connect()
  30. import webnotes.modules.patch_handler
  31. from webnotes.modules.patch_handler import run_all, run_single, reload_doc
  32. class TestPatch(unittest.TestCase):
  33. def test_run_single(self):
  34. webnotes.modules.patch_handler.log_list = []
  35. run_single('patches.jan_mar_2012.subdomain_login_patch')
  36. print webnotes.modules.patch_handler.log_list
  37. self.assertTrue(webnotes.conn.sql("""select patch from __PatchLog
  38. where patch='subdomain_login_patch'"""))
  39. webnotes.conn.sql( """delete from __PatchLog
  40. where patch='subdomain_login_patch'""")
  41. def test_reload(self):
  42. webnotes.modules.patch_handler.log_list = []
  43. mod1 = webnotes.conn.sql("""select modified from tabDocType
  44. where name='Print Format'""")[0][0]
  45. reload_doc({"module":"core", "dt":"DocType", "dn":"Print Format"})
  46. print webnotes.modules.patch_handler.log_list
  47. mod2 = webnotes.conn.sql("""select modified from tabDocType
  48. where name='Print Format'""")[0][0]
  49. self.assertNotEquals(mod1, mod2)
  50. def test_multiple(self):
  51. webnotes.modules.patch_handler.log_list = []
  52. run_all([{"patch_file":"subdomain_login_patch", "patch_module":"patches.jan_mar_2012"}])
  53. webnotes.conn.sql( """delete from __PatchLog
  54. where patch='subdomain_login_patch'""")
  55. print webnotes.modules.patch_handler.log_list
  56. if __name__=='__main__':
  57. unittest.main()