Mercurial > hgsubversion
annotate tests/test_helpers.py @ 1002:117b3b421294
buildmeta: verify uuid when passed explicit url
2c87bdc43d3c changed buildmeta to read the uuid from local disk, if
it's available. As a side effect, it disabled the validation of the
uuid we've recorded locall in the commits against the uuid of the repo
we are building against. This is probably reasonable when someone
runs a bare updatemeta or rebuildmeta. I think it's a worthwhile
sanity check when someone passes an explicit repository url to
rebuild/updatemeta. This restores the validation in that case, and
fixes a failing test in the process.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Fri, 12 Apr 2013 10:51:42 -0700 |
parents | bfbfc9be3faa |
children | d741f536f23a |
rev | line source |
---|---|
945
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
1 import os, sys, unittest |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
2 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
3 _rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
4 sys.path.insert(0, _rootdir) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
5 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
6 from hgsubversion import editor |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
7 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
8 class TestHelpers(unittest.TestCase): |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
9 def test_filestore(self): |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
10 fs = editor.FileStore(2) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
11 fs.setfile('a', 'a') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
12 fs.setfile('b', 'b') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
13 self.assertEqual('a', fs._data.get('a')) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
14 self.assertEqual('b', fs._data.get('b')) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
15 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
16 fs.delfile('b') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
17 self.assertRaises(IOError, lambda: fs.getfile('b')) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
18 fs.setfile('bb', 'bb') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
19 self.assertTrue('bb' in fs._files) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
20 self.assertTrue('bb' not in fs._data) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
21 self.assertEqual('bb', fs.getfile('bb')) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
22 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
23 fs.delfile('bb') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
24 self.assertTrue('bb' not in fs._files) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
25 self.assertEqual([], os.listdir(fs._tempdir)) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
26 self.assertRaises(IOError, lambda: fs.getfile('bb')) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
27 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
28 fs.setfile('bb', 'bb') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
29 self.assertEqual(1, len(os.listdir(fs._tempdir))) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
30 fs.popfile('bb') |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
31 self.assertEqual([], os.listdir(fs._tempdir)) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
32 self.assertRaises(editor.EditingError, lambda: fs.getfile('bb')) |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
33 |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
34 def suite(): |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
35 return unittest.TestSuite([ |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
36 unittest.TestLoader().loadTestsFromTestCase(TestHelpers), |
bfbfc9be3faa
editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents:
diff
changeset
|
37 ]) |