~ubuntu-branches/ubuntu/oneiric/dulwich/oneiric

« back to all changes in this revision

Viewing changes to dulwich/tests/test_object_store.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-07-30 13:22:11 UTC
  • mfrom: (1.2.11 upstream) (8.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100730132211-k6aop8v5z42mawef
Tags: 0.6.1-1
* New upstream release.
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17
17
# MA  02110-1301, USA.
18
18
 
19
 
 
20
19
"""Tests for the object store interface."""
21
20
 
22
21
 
23
22
import os
24
23
import shutil
25
24
import tempfile
26
 
from unittest import TestCase
27
25
 
28
26
from dulwich.objects import (
29
27
    Blob,
32
30
    DiskObjectStore,
33
31
    MemoryObjectStore,
34
32
    )
 
33
from dulwich.tests import (
 
34
    TestCase,
 
35
    )
35
36
from utils import (
36
37
    make_object,
37
38
    )
82
83
        self.store = MemoryObjectStore()
83
84
 
84
85
 
85
 
class DiskObjectStoreTests(ObjectStoreTests, TestCase):
 
86
class PackBasedObjectStoreTests(ObjectStoreTests):
 
87
 
 
88
    def test_empty_packs(self):
 
89
        self.assertEquals([], self.store.packs)
 
90
 
 
91
    def test_pack_loose_objects(self):
 
92
        b1 = make_object(Blob, data="yummy data")
 
93
        self.store.add_object(b1)
 
94
        b2 = make_object(Blob, data="more yummy data")
 
95
        self.store.add_object(b2)
 
96
        self.assertEquals([], self.store.packs)
 
97
        self.assertEquals(2, self.store.pack_loose_objects())
 
98
        self.assertNotEquals([], self.store.packs)
 
99
        self.assertEquals(0, self.store.pack_loose_objects())
 
100
 
 
101
 
 
102
class DiskObjectStoreTests(PackBasedObjectStoreTests, TestCase):
86
103
 
87
104
    def setUp(self):
88
105
        TestCase.setUp(self)
97
114
        o = DiskObjectStore(self.store_dir)
98
115
        self.assertEquals(os.path.join(self.store_dir, "pack"), o.pack_dir)
99
116
 
100
 
    def test_empty_packs(self):
101
 
        o = DiskObjectStore(self.store_dir)
102
 
        self.assertEquals([], o.packs)
103
 
 
104
 
 
105
117
# TODO: MissingObjectFinderTests