Ejemplo n.º 1
0
    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"
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
  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)
Ejemplo n.º 7
0
 def test_str_should_alias_name(self):
     a = Actor._from_string("Michael Trier <*****@*****.**>")
     self.assertEqual(a.name, str(a))
Ejemplo n.º 8
0
 def test_should_display_representation(self):
     a = Actor._from_string("Michael Trier <*****@*****.**>")
     self.assertEqual('<git.Actor "Michael Trier <*****@*****.**>">', repr(a))
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 def test_str_should_alias_name(self):
     a = Actor._from_string("Michael Trier <*****@*****.**>")
     assert_equal(a.name, str(a))
Ejemplo n.º 11
0
 def test_should_display_representation(self):
     a = Actor._from_string("Michael Trier <*****@*****.**>")
     assert_equal('<git.Actor "Michael Trier <*****@*****.**>">', repr(a))
Ejemplo n.º 12
0
 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)