Changeset 729:0e295374422f in hatta-dev
- Timestamp:
- 01/21/10 17:53:17 (2 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
tests/test_repo.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/test_repo.py
r635 r729 1 1 #!/usr/bin/python 2 2 # -*- coding: utf-8 -*- 3 4 """ 5 This is a set of unit tests for testing the repository storage of Hatta wiki 6 engine. To run it, run py.test (at least version 1.0) from the main Hatta 7 directory. 8 """ 3 9 4 10 import os … … 10 16 11 17 def clear_directory(top): 18 """ 19 A helper function to remove a directory with all its contents. 20 """ 21 12 22 for root, dirs, files in os.walk(top, topdown=False): 13 23 for name in files: … … 21 31 22 32 def pytest_funcarg__repo(request): 33 """ 34 This function is executed whenever a test needs a "repo" parameter. 35 It creates a new WikiStorage object with Hatta repository in a 36 temporary directory. 37 """ 38 23 39 repo_path = str(request.config.ensuretemp('repo')) 24 40 request.addfinalizer(lambda: clear_directory(repo_path)) … … 26 42 27 43 class TestMercurialStorage(object): 44 """ 45 This class groups the general tests for Hatta storage that should 46 always pass, no matter what configuration is used. 47 """ 48 28 49 def test_save_text(self, repo): 50 """ 51 Create a page and read its contents, verify that it matches. 52 """ 53 29 54 text = u"test text" 30 55 title = u"test title" … … 36 61 37 62 def test_save_text_noparent(self, repo): 63 """ 64 Save a page with parent set to None. 65 """ 66 38 67 text = u"test text" 39 68 title = u"test title" … … 45 74 46 75 def test_save_merge_no_conflict(self, repo): 76 """ 77 Create a page two times, with the same content. Verify that 78 it is merged correctly. 79 """ 80 47 81 text = u"test\ntext" 48 82 title = u"test title" … … 55 89 56 90 def test_save_merge_line_conflict(self, repo): 57 text = u"123\n456\n789" 58 text1 = u"123\n000\n789" 59 text2 = u"123\n111\n789" 91 """ 92 Modify a page twice, saving conflicting content. Verify that merge 93 markers are inserted properly. 94 """ 95 96 text = u"""\ 97 123 98 456 99 789""" 100 text1 = u"""\ 101 123 102 000 103 789""" 104 text2 = u"""\ 105 123 106 111 107 789""" 60 108 title = u"test title" 61 109 author = u"test author" … … 65 113 repo.save_text(title, text2, author, comment, parent=0) 66 114 saved = repo.open_page(title).read() 67 assert saved == "123\n<<<<<<< local\n111\n=======\n000\n>>>>>>> other\n789" 115 assert saved == u"""\ 116 123 117 <<<<<<< local 118 111 119 ======= 120 000 121 >>>>>>> other 122 789""" 68 123 69 124 def test_delete(self, repo): 125 """ 126 Create and delete a page. 127 """ 128 70 129 text = u"text test" 71 130 title = u"test title"
Note: See TracChangeset
for help on using the changeset viewer.
