56
def assertUnsigned(self, repo, revision_id):
57
"""Assert that revision_id is not signed in repo."""
58
self.assertFalse(repo.has_signature_for_revision_id(revision_id))
60
def assertSigned(self, repo, revision_id):
61
"""Assert that revision_id is signed in repo."""
62
self.assertTrue(repo.has_signature_for_revision_id(revision_id))
56
64
def test_sign_my_commits(self):
57
65
#Test re signing of data.
58
66
wt = self.setup_tree()
61
69
self.monkey_patch_gpg()
63
self.assertFalse(repo.revision_store.has_id('A', 'sig'))
64
self.assertFalse(repo.revision_store.has_id('B', 'sig'))
65
self.assertFalse(repo.revision_store.has_id('C', 'sig'))
66
self.assertFalse(repo.revision_store.has_id('D', 'sig'))
71
self.assertUnsigned(repo, 'A')
72
self.assertUnsigned(repo, 'B')
73
self.assertUnsigned(repo, 'C')
74
self.assertUnsigned(repo, 'D')
68
76
self.run_bzr('sign-my-commits')
70
self.assertTrue(repo.revision_store.has_id('A', 'sig'))
71
self.assertTrue(repo.revision_store.has_id('B', 'sig'))
72
self.assertTrue(repo.revision_store.has_id('C', 'sig'))
73
self.assertFalse(repo.revision_store.has_id('D', 'sig'))
78
self.assertSigned(repo, 'A')
79
self.assertSigned(repo, 'B')
80
self.assertSigned(repo, 'C')
81
self.assertUnsigned(repo, 'D')
75
83
def test_sign_my_commits_location(self):
76
84
wt = self.setup_tree('other')
81
89
self.run_bzr('sign-my-commits', 'other')
83
self.assertTrue(repo.revision_store.has_id('A', 'sig'))
84
self.assertTrue(repo.revision_store.has_id('B', 'sig'))
85
self.assertTrue(repo.revision_store.has_id('C', 'sig'))
86
self.assertFalse(repo.revision_store.has_id('D', 'sig'))
91
self.assertSigned(repo, 'A')
92
self.assertSigned(repo, 'B')
93
self.assertSigned(repo, 'C')
94
self.assertUnsigned(repo, 'D')
88
96
def test_sign_diff_committer(self):
89
97
wt = self.setup_tree()
94
102
self.run_bzr('sign-my-commits', '.', 'Alternate <alt@foo.com>')
96
self.assertFalse(repo.revision_store.has_id('A', 'sig'))
97
self.assertFalse(repo.revision_store.has_id('B', 'sig'))
98
self.assertFalse(repo.revision_store.has_id('C', 'sig'))
99
self.assertTrue(repo.revision_store.has_id('D', 'sig'))
104
self.assertUnsigned(repo, 'A')
105
self.assertUnsigned(repo, 'B')
106
self.assertUnsigned(repo, 'C')
107
self.assertSigned(repo, 'D')
101
109
def test_sign_dry_run(self):
102
110
wt = self.setup_tree()
107
115
out = self.run_bzr('sign-my-commits', '--dry-run')[0]
109
117
self.assertEquals('A\nB\nC\nSigned 3 revisions\n', out)
110
self.assertFalse(repo.revision_store.has_id('A', 'sig'))
111
self.assertFalse(repo.revision_store.has_id('B', 'sig'))
112
self.assertFalse(repo.revision_store.has_id('C', 'sig'))
113
self.assertFalse(repo.revision_store.has_id('D', 'sig'))
118
self.assertUnsigned(repo, 'A')
119
self.assertUnsigned(repo, 'B')
120
self.assertUnsigned(repo, 'C')
121
self.assertUnsigned(repo, 'D')