summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing/journaltest.py
diff options
context:
space:
mode:
Diffstat (limited to 'rdiff-backup/testing/journaltest.py')
-rw-r--r--rdiff-backup/testing/journaltest.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/rdiff-backup/testing/journaltest.py b/rdiff-backup/testing/journaltest.py
new file mode 100644
index 0000000..76e638a
--- /dev/null
+++ b/rdiff-backup/testing/journaltest.py
@@ -0,0 +1,29 @@
+from commontest import *
+import unittest
+from rdiff_backup import journal, Globals, rpath
+
+class JournalTest(unittest.TestCase):
+ def testBasic(self):
+ """Test opening a journal, then reading, writing, and deleting"""
+ MakeOutputDir()
+ Globals.rbdir = rpath.RPath(Globals.local_connection,
+ "testfiles/output")
+ journal.open_journal()
+ assert len(journal.get_entries_from_journal()) == 0
+
+ # It's important that none of these files really exist
+ e1 = journal.write_entry("Hello48", "reg", "inc_file3917", "t39p")
+ e2 = journal.write_entry("2nd_euoeuo", None, "inc_file4832", "l389")
+ assert e1.entry_rp and e2.entry_rp
+
+ l = journal.get_entries_from_journal()
+ assert len(l) == 2
+ first_filename = l[0].test_filename
+ assert first_filename == "Hello48" or first_filename == "2nd_euoeuo"
+
+ # Now test recovering journal, and make sure everything deleted
+ journal.recover_journal()
+ assert len(journal.get_entries_from_journal()) == 0
+
+
+if __name__ == "__main__": unittest.main()