def test_stats(self): commit = self.rorepo.commit('33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats def check_entries(d): assert isinstance(d, dict) for key in ("insertions", "deletions", "lines"): assert key in d # END assertion helper assert stats.files assert stats.total check_entries(stats.total) assert "files" in stats.total for filepath, d in stats.files.items(): check_entries(d) # END for each stated file # assure data is parsed properly michael = Actor._from_string("Michael Trier <*****@*****.**>") assert commit.author == michael assert commit.committer == michael assert commit.authored_date == 1210193388 assert commit.committed_date == 1210193388 assert commit.author_tz_offset == 14400, commit.author_tz_offset assert commit.committer_tz_offset == 14400, commit.committer_tz_offset assert commit.message == "initial project\n"
def test_unicode_actor(self): # assure we can parse unicode actors correctly name = u"Üäöß ÄußÉ" self.assertEqual(len(name), 9) special = Actor._from_string(u"%s <*****@*****.**>" % name) self.assertEqual(special.name, name) assert isinstance(special.name, str)
def test_unicode_actor(self): # assure we can parse unicode actors correctly name = u"Üäöß ÄußÉ" assert len(name) == 9 special = Actor._from_string(u"%s <*****@*****.**>" % name) assert special.name == name assert isinstance(special.name, text_type)
def test_from_string_should_separate_name_and_email(self): a = Actor._from_string("Michael Trier <*****@*****.**>") self.assertEqual("Michael Trier", a.name) self.assertEqual("*****@*****.**", a.email) # base type capabilities assert a == a assert not (a != a) m = set() m.add(a) m.add(a) assert len(m) == 1
def test_from_string_should_separate_name_and_email(self): a = Actor._from_string("Michael Trier <*****@*****.**>") assert_equal("Michael Trier", a.name) assert_equal("*****@*****.**", a.email) # base type capabilities assert a == a assert not (a != a) m = set() m.add(a) m.add(a) assert len(m) == 1
def apply_mailbox_patch(self, filename, committer=None, commit_date=None): git_environment = {} if committer is not None: committer_actor = Actor._from_string(committer) git_environment['GIT_COMMITTER_NAME'] = committer_actor.name git_environment['GIT_COMMITTER_EMAIL'] = committer_actor.email if commit_date is not None: git_environment['GIT_COMMITTER_DATE'] = str(commit_date) full_patch_path = self._relative_to_absolute_path(filename) with self.repo.git.custom_environment(**git_environment): return self.repo.git.am('--keep-non-patch', full_patch_path)
def test_str_should_alias_name(self): a = Actor._from_string("Michael Trier <*****@*****.**>") self.assertEqual(a.name, str(a))
def test_should_display_representation(self): a = Actor._from_string("Michael Trier <*****@*****.**>") self.assertEqual('<git.Actor "Michael Trier <*****@*****.**>">', repr(a))
def test_from_string_should_handle_just_name(self): a = Actor._from_string("Michael Trier") self.assertEqual("Michael Trier", a.name) self.assertEqual(None, a.email)
def test_str_should_alias_name(self): a = Actor._from_string("Michael Trier <*****@*****.**>") assert_equal(a.name, str(a))
def test_should_display_representation(self): a = Actor._from_string("Michael Trier <*****@*****.**>") assert_equal('<git.Actor "Michael Trier <*****@*****.**>">', repr(a))
def test_from_string_should_handle_just_name(self): a = Actor._from_string("Michael Trier") assert_equal("Michael Trier", a.name) assert_equal(None, a.email)