Show More
@@ -34,10 +34,11 b' py_class!(pub class PartialDiscovery |py' | |||||
34 | // implemented. |
|
34 | // implemented. | |
35 | def __new__( |
|
35 | def __new__( | |
36 | _cls, |
|
36 | _cls, | |
37 |
|
|
37 | repo: PyObject, | |
38 | targetheads: PyObject, |
|
38 | targetheads: PyObject, | |
39 | _respectsize: bool |
|
39 | _respectsize: bool | |
40 | ) -> PyResult<PartialDiscovery> { |
|
40 | ) -> PyResult<PartialDiscovery> { | |
|
41 | let index = repo.getattr(py, "changelog")?.getattr(py, "index")?; | |||
41 | Self::create_instance( |
|
42 | Self::create_instance( | |
42 | py, |
|
43 | py, | |
43 | RefCell::new(Box::new(CorePartialDiscovery::new( |
|
44 | RefCell::new(Box::new(CorePartialDiscovery::new( |
@@ -31,6 +31,11 b' data_non_inlined = (' | |||||
31 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
|
31 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |
32 | ) |
|
32 | ) | |
33 |
|
33 | |||
|
34 | class fakerepo(object): | |||
|
35 | def __init__(self, idx): | |||
|
36 | """Just make so that self.changelog.index is the given idx.""" | |||
|
37 | self.index = idx | |||
|
38 | self.changelog = self | |||
34 |
|
39 | |||
35 | @unittest.skipIf(PartialDiscovery is None or cparsers is None, |
|
40 | @unittest.skipIf(PartialDiscovery is None or cparsers is None, | |
36 | "rustext or the C Extension parsers module " |
|
41 | "rustext or the C Extension parsers module " | |
@@ -50,6 +55,9 b' class rustdiscoverytest(unittest.TestCas' | |||||
50 | def parseindex(self): |
|
55 | def parseindex(self): | |
51 | return cparsers.parse_index2(data_non_inlined, False)[0] |
|
56 | return cparsers.parse_index2(data_non_inlined, False)[0] | |
52 |
|
57 | |||
|
58 | def repo(self): | |||
|
59 | return fakerepo(self.parseindex()) | |||
|
60 | ||||
53 | def testindex(self): |
|
61 | def testindex(self): | |
54 | idx = self.parseindex() |
|
62 | idx = self.parseindex() | |
55 | # checking our assumptions about the index binary data: |
|
63 | # checking our assumptions about the index binary data: | |
@@ -60,8 +68,7 b' class rustdiscoverytest(unittest.TestCas' | |||||
60 | 3: (2, -1)}) |
|
68 | 3: (2, -1)}) | |
61 |
|
69 | |||
62 | def testaddcommonsmissings(self): |
|
70 | def testaddcommonsmissings(self): | |
63 | idx = self.parseindex() |
|
71 | disco = PartialDiscovery(self.repo(), [3], True) | |
64 | disco = PartialDiscovery(idx, [3], True) |
|
|||
65 | self.assertFalse(disco.hasinfo()) |
|
72 | self.assertFalse(disco.hasinfo()) | |
66 | self.assertFalse(disco.iscomplete()) |
|
73 | self.assertFalse(disco.iscomplete()) | |
67 |
|
74 | |||
@@ -76,24 +83,21 b' class rustdiscoverytest(unittest.TestCas' | |||||
76 | self.assertEqual(disco.commonheads(), {1}) |
|
83 | self.assertEqual(disco.commonheads(), {1}) | |
77 |
|
84 | |||
78 | def testaddmissingsstats(self): |
|
85 | def testaddmissingsstats(self): | |
79 | idx = self.parseindex() |
|
86 | disco = PartialDiscovery(self.repo(), [3], True) | |
80 | disco = PartialDiscovery(idx, [3], True) |
|
|||
81 | self.assertIsNone(disco.stats()['undecided'], None) |
|
87 | self.assertIsNone(disco.stats()['undecided'], None) | |
82 |
|
88 | |||
83 | disco.addmissings([2]) |
|
89 | disco.addmissings([2]) | |
84 | self.assertEqual(disco.stats()['undecided'], 2) |
|
90 | self.assertEqual(disco.stats()['undecided'], 2) | |
85 |
|
91 | |||
86 | def testaddinfocommonfirst(self): |
|
92 | def testaddinfocommonfirst(self): | |
87 | idx = self.parseindex() |
|
93 | disco = PartialDiscovery(self.repo(), [3], True) | |
88 | disco = PartialDiscovery(idx, [3], True) |
|
|||
89 | disco.addinfo([(1, True), (2, False)]) |
|
94 | disco.addinfo([(1, True), (2, False)]) | |
90 | self.assertTrue(disco.hasinfo()) |
|
95 | self.assertTrue(disco.hasinfo()) | |
91 | self.assertTrue(disco.iscomplete()) |
|
96 | self.assertTrue(disco.iscomplete()) | |
92 | self.assertEqual(disco.commonheads(), {1}) |
|
97 | self.assertEqual(disco.commonheads(), {1}) | |
93 |
|
98 | |||
94 | def testaddinfomissingfirst(self): |
|
99 | def testaddinfomissingfirst(self): | |
95 | idx = self.parseindex() |
|
100 | disco = PartialDiscovery(self.repo(), [3], True) | |
96 | disco = PartialDiscovery(idx, [3], True) |
|
|||
97 | disco.addinfo([(2, False), (1, True)]) |
|
101 | disco.addinfo([(2, False), (1, True)]) | |
98 | self.assertTrue(disco.hasinfo()) |
|
102 | self.assertTrue(disco.hasinfo()) | |
99 | self.assertTrue(disco.iscomplete()) |
|
103 | self.assertTrue(disco.iscomplete()) |
General Comments 0
You need to be logged in to leave comments.
Login now