~ubuntu-branches/ubuntu/saucy/dulwich/saucy-proposed

« back to all changes in this revision

Viewing changes to dulwich/tests/test_server.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2011-12-18 21:35:03 UTC
  • mfrom: (1.2.18)
  • Revision ID: package-import@ubuntu.com-20111218213503-a1cmlg9kr1smxgg6
Tags: 0.8.2-1
* Fix Vcs URL.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    ReceivePackHandler,
45
45
    SingleAckGraphWalkerImpl,
46
46
    UploadPackHandler,
 
47
    update_server_info,
47
48
    )
48
49
from dulwich.tests import TestCase
49
50
from dulwich.tests.utils import (
689
690
            outlines[0][4:].split("\x00")[0])
690
691
        self.assertEquals("0000", outlines[-1])
691
692
        self.assertEquals(0, exitcode)
 
693
 
 
694
 
 
695
class UpdateServerInfoTests(TestCase):
 
696
    """Tests for update_server_info."""
 
697
 
 
698
    def setUp(self):
 
699
        super(UpdateServerInfoTests, self).setUp()
 
700
        self.path = tempfile.mkdtemp()
 
701
        self.repo = Repo.init(self.path)
 
702
 
 
703
    def test_empty(self):
 
704
        update_server_info(self.repo)
 
705
        self.assertEquals("",
 
706
            open(os.path.join(self.path, ".git", "info", "refs"), 'r').read())
 
707
        self.assertEquals("",
 
708
            open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'r').read())
 
709
 
 
710
    def test_simple(self):
 
711
        commit_id = self.repo.do_commit(
 
712
            message="foo",
 
713
            committer="Joe Example <joe@example.com>",
 
714
            ref="refs/heads/foo")
 
715
        update_server_info(self.repo)
 
716
        ref_text = open(os.path.join(self.path, ".git", "info", "refs"), 'r').read()
 
717
        self.assertEquals(ref_text, "%s\trefs/heads/foo\n" % commit_id)
 
718
        packs_text = open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'r').read()
 
719
        self.assertEquals(packs_text, "")