def test_addChange_noprefix(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange(dict(who="bar", files=['a'])) def check(_): self.assertEqual(self.added_changes, [ dict(author="bar", files=['a']) ]) d.addCallback(check) return d
def testPrefix3(self): p = pb.ChangePerspective(self, "trunk/") p.perspective_addChange(d4) self.failUnlessEqual(len(self.changes), 1) c1 = self.changes[-1] self.failUnlessEqual(set(c1.files), set(["baz.c", "bar.c"])) self.failUnlessEqual(c1.comments, "mixed changes")
def testPrefix4(self): p = pb.ChangePerspective(self, "branches/foobranch/") p.perspective_addChange(d4) self.failUnlessEqual(len(self.changes), 1) c1 = self.changes[-1] self.failUnlessEqual(set(c1.files), set(["foo.c"])) self.failUnlessEqual(c1.comments, "mixed changes")
def testNoPrefix(self): p = pb.ChangePerspective(self, None) p.perspective_addChange(d1) self.failUnlessEqual(len(self.changes), 1) c1 = self.changes[0] self.failUnlessEqual(c1.files, ["Project/foo.c", "Project/bar/boo.c"]) self.failUnlessEqual(c1.comments, "Some changes in Project") self.failUnlessEqual(c1.who, "marvin")
def test_addChange_files_tuple(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange(dict(files=('a', 'b'))) def check(_): self.assertEqual(self.added_changes, [dict(files=['a', 'b'])]) d.addCallback(check) return d
def test_createUserObject_git_src(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange(dict(who="c <h@c>", src='git')) def check_change(_): self.assertEqual(self.added_changes, [ dict(author="c <h@c>", files=[], src='git') ]) d.addCallback(check_change) return d
def test_addChange_sanitize_None(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange( dict(project=None, revlink=None, repository=None) ) def check(_): self.assertEqual(self.added_changes, [ dict(project="", revlink="", repository="", files=[]) ]) d.addCallback(check) return d
def test_addChange_when_None(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange( dict(when=None) ) def check(_): self.assertEqual(self.added_changes, [ dict(when_timestamp=None, files=[]) ]) d.addCallback(check) return d
def test_addChange_non_utf8_bytestring(self): cp = pb.ChangePerspective(self.master, None) bogus_utf8 = '\xff\xff\xff\xff' replacement = bogus_utf8.decode('utf8', 'replace') d = cp.perspective_addChange(dict(author=bogus_utf8, files=['a'])) def check(_): self.assertEqual(self.added_changes, [ dict(author=replacement, files=['a']) ]) d.addCallback(check) return d
def test_addChange_old_param_names(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange(dict(isdir=1, who='me', when=1234, files=[])) def check(_): self.assertEqual(self.added_changes, [ dict(is_dir=1, author='me', files=[], when_timestamp=epoch2datetime(1234)) ]) d.addCallback(check) return d
def test_addChange_unicode_as_bytestring(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange(dict(author=u"\N{SNOWMAN}".encode('utf8'), comments=u"\N{SNOWMAN}".encode('utf8'), files=[u'\N{VERY MUCH GREATER-THAN}'.encode('utf8')])) def check(_): self.assertEqual(self.added_changes, [ dict(author=u"\N{SNOWMAN}", comments=u"\N{SNOWMAN}", files=[u'\N{VERY MUCH GREATER-THAN}']) ]) d.addCallback(check) return d
def testPrefix2(self): p = pb.ChangePerspective(self, "Project/bar/") p.perspective_addChange(d1) self.failUnlessEqual(len(self.changes), 1) c1 = self.changes[-1] self.failUnlessEqual(c1.files, ["boo.c"]) self.failUnlessEqual(c1.comments, "Some changes in Project") self.failUnlessEqual(c1.who, "marvin") p.perspective_addChange(d2) # should be ignored self.failUnlessEqual(len(self.changes), 1) p.perspective_addChange(d3) # should ignore this too self.failUnlessEqual(len(self.changes), 1)
def test_addChange_unicode(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange( dict(author=u"\N{SNOWMAN}", comments=u"\N{SNOWMAN}", links=[u'\N{HEAVY BLACK HEART}'], files=[u'\N{VERY MUCH GREATER-THAN}'])) def check(_): self.assertEqual(self.added_changes, [ dict(author=u"\N{SNOWMAN}", comments=u"\N{SNOWMAN}", links=[u'\N{HEAVY BLACK HEART}'], files=[u'\N{VERY MUCH GREATER-THAN}']) ]) d.addCallback(check) return d
def test_addChange_codebase(self): cp = pb.ChangePerspective(self.master, None) yield cp.perspective_addChange(dict(who="bar", files=[], codebase='cb')) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': u'bar', 'branch': None, 'category': None, 'codebase': u'cb', 'comments': None, 'files': [], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': None, }])
def test_createUserObject_git_src(self): cp = pb.ChangePerspective(self.master, None) yield cp.perspective_addChange(dict(who="c <h@c>", src='git')) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': u'c <h@c>', 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': [], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': u'git', 'when_timestamp': None, }])
def testPrefix(self): p = pb.ChangePerspective(self, "Project/") p.perspective_addChange(d1) self.failUnlessEqual(len(self.changes), 1) c1 = self.changes[-1] self.failUnlessEqual(c1.files, ["foo.c", "bar/boo.c"]) self.failUnlessEqual(c1.comments, "Some changes in Project") self.failUnlessEqual(c1.who, "marvin") p.perspective_addChange(d2) # should be ignored self.failUnlessEqual(len(self.changes), 1) p.perspective_addChange(d3) # should ignore the OtherProject file self.failUnlessEqual(len(self.changes), 2) c3 = self.changes[-1] self.failUnlessEqual(c3.files, ["baz.c"]) self.failUnlessEqual(c3.comments, "mixed changes") self.failUnlessEqual(c3.who, "alice")
def test_addChange_old_param_names(self): cp = pb.ChangePerspective(self.master, None) yield cp.perspective_addChange(dict(who='me', when=1234, files=[])) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': u'me', 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': [], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': 1234, }])
def test_addChange_sanitize_None(self): cp = pb.ChangePerspective(self.master, None) yield cp.perspective_addChange( dict(project=None, revlink=None, repository=None)) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': None, 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': [], 'project': u'', 'properties': {}, 'repository': u'', 'revision': None, 'revlink': u'', 'src': None, 'when_timestamp': None, }])
def test_addChange_unicode(self): cp = pb.ChangePerspective(self.master, None) yield cp.perspective_addChange(dict(author=u"\N{SNOWMAN}", comments=u"\N{SNOWMAN}", files=[u'\N{VERY MUCH GREATER-THAN}'])) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': u'\u2603', 'branch': None, 'category': None, 'codebase': None, 'comments': u'\u2603', 'files': [u'\u22d9'], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': None, }])
def test_addChange_non_utf8_bytestring(self): cp = pb.ChangePerspective(self.master, None) bogus_utf8 = b'\xff\xff\xff\xff' replacement = bogus_utf8.decode('utf8', 'replace') yield cp.perspective_addChange(dict(author=bogus_utf8, files=['a'])) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': replacement, 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': [u'a'], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': None, }])
def test_addChange_prefix(self): cp = pb.ChangePerspective(self.master, 'xx/') yield cp.perspective_addChange(dict(who="bar", files=['xx/a', 'yy/b'])) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': 'bar', 'committer': None, 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': ['a'], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': None, }])
def test_addChange_files_tuple(self): cp = pb.ChangePerspective(self.master, None) yield cp.perspective_addChange(dict(files=('a', 'b'))) self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': None, 'committer': None, 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': ['a', 'b'], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': None, }])
def test_addChange_when_None(self): cp = pb.ChangePerspective(self.master, None) d = cp.perspective_addChange(dict(when=None)) def check(_): self.assertEqual(self.master.data.updates.changesAdded, [{ 'author': None, 'branch': None, 'category': None, 'codebase': None, 'comments': None, 'files': [], 'project': '', 'properties': {}, 'repository': '', 'revision': None, 'revlink': '', 'src': None, 'when_timestamp': None, }]) d.addCallback(check) return d
def testCategory(self): p = pb.ChangePerspective(self, None) p.perspective_addChange(d5) self.failUnlessEqual(len(self.changes), 1) c1 = self.changes[0] self.failUnlessEqual(c1.category, "categoryA")