Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

Add more tests.

Changeset 8c7f974e5bdb

Parent 3181fba5c92f

by Jelmer Vernooij

Changes to 2 files · Browse files at 8c7f974e5bdb Showing diff from parent 3181fba5c92f Diff from another changeset...

 
369
370
371
372
 
373
374
375
 
369
370
371
 
372
373
374
375
@@ -369,7 +369,7 @@
    :param objects: Iterable over a list of objects.   """ - for obj in objects: + for obj, path in objects:   self._data[obj.id] = obj    
 
22
23
24
 
 
 
25
26
27
28
29
 
30
31
32
 
 
 
 
 
33
34
35
 
39
40
41
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
44
 
45
46
47
48
49
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
52
53
 
54
55
56
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
36
37
38
39
40
41
42
43
 
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
 
64
65
66
 
67
68
 
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
87
88
 
 
 
89
90
91
92
93
94
95
96
97
98
99
100
101
@@ -22,14 +22,22 @@
   from unittest import TestCase   +from dulwich.objects import ( + Blob, + )  from dulwich.object_store import (   DiskObjectStore,   MemoryObjectStore,   )  import os +import shutil     -class DiskObjectStoreTests(TestCase): +testobject = Blob() +testobject.data = "yummy data" + + +class SpecificDiskObjectStoreTests(TestCase):     def test_pack_dir(self):   o = DiskObjectStore("foo") @@ -39,19 +47,55 @@
  o = DiskObjectStore("foo")   self.assertEquals([], o.packs)   + + +class ObjectStoreTests(object): + + def test_iter(self): + self.assertEquals([], list(self.store)) + + def test_get_nonexistant(self): + self.assertRaises(KeyError, self.store.__getitem__, "a" * 40) + + def test_contains_nonexistant(self): + self.assertFalse(self.store.__contains__("a" * 40)) +   def test_add_objects_empty(self): - o = DiskObjectStore("foo") - o.add_objects([]) + self.store.add_objects([])     def test_add_commit(self): - o = DiskObjectStore("foo")   # TODO: Argh, no way to construct Git commit objects without   # access to a serialized form. - o.add_objects([]) + self.store.add_objects([]) + + def test_add_object(self): + self.store.add_object(testobject) + self.assertEquals(set([testobject.id]), set(self.store)) + self.assertTrue(self.store.__contains__(testobject.id)) + r = self.store[testobject.id] + self.assertEquals(r, testobject) + + def test_add_objects(self): + data = [(testobject, "mypath")] + self.store.add_objects(data) + self.assertEquals(set([testobject.id]), set(self.store)) + self.assertTrue(self.store.__contains__(testobject.id)) + r = self.store[testobject.id] + self.assertEquals(r, testobject)     -class MemoryObjectStoreTests(TestCase): +class MemoryObjectStoreTests(ObjectStoreTests,TestCase):   - def test_iter(self): - store = MemoryObjectStore() - self.assertEquals([], list(store)) + def setUp(self): + TestCase.setUp(self) + self.store = MemoryObjectStore() + + +class DiskObjectStoreTests(ObjectStoreTests,TestCase): + + def setUp(self): + TestCase.setUp(self) + if os.path.exists("foo"): + shutil.rmtree("foo") + os.makedirs(os.path.join("foo", "pack")) + self.store = DiskObjectStore("foo")