lockss-turtles 0.6.0.dev24__py3-none-any.whl → 0.6.0.dev26__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,50 +28,247 @@
28
28
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
29
  # POSSIBILITY OF SUCH DAMAGE.
30
30
 
31
+ # Remove in Python 3.14
32
+ # See https://stackoverflow.com/questions/33533148/how-do-i-type-hint-a-method-with-the-type-of-the-enclosing-class/33533514#33533514
33
+ from __future__ import annotations
34
+
35
+ from abc import ABC, abstractmethod
31
36
  from pathlib import Path
32
37
 
33
- from . import PydanticTestCase
34
- from lockss.turtles.plugin_set import AntPluginSetBuilder, MavenPluginSetBuilder, PluginSet, PluginSetBuilder, PluginSetBuilderType
38
+ from . import PydanticTestCase, ROOT
39
+ from lockss.turtles.plugin_set import AntPluginSetBuilder, BasePluginSetBuilder, MavenPluginSetBuilder, PluginSet, PluginSetBuilderType, PluginSetCatalog
35
40
 
36
41
 
37
- ROOT: Path = Path('.').absolute()
42
+ class TestPluginSetCatalog(PydanticTestCase):
38
43
 
44
+ def setUp(self) -> None:
45
+ super().setUp()
46
+ self.valid_absolute = PluginSetCatalog(**{'kind': 'PluginSetCatalog',
47
+ 'plugin-set-files': [
48
+ '/tmp/one.yaml'
49
+ ]}).initialize(ROOT)
50
+ self.valid_relative = PluginSetCatalog(**{'kind': 'PluginSetCatalog',
51
+ 'plugin-set-files': [
52
+ 'one.yaml'
53
+ ]}).initialize(ROOT)
54
+ self.valid = [self.valid_absolute, self.valid_relative]
39
55
 
40
- class TestPluginSet(PydanticTestCase):
56
+ def test_missing_kind(self) -> None:
57
+ self.assertPydanticMissing(lambda: PluginSetCatalog(),
58
+ 'kind')
59
+
60
+ def test_null_kind(self) -> None:
61
+ self.assertPydanticLiteralError(lambda: PluginSetCatalog(kind=None),
62
+ 'kind',
63
+ 'PluginSetCatalog')
64
+
65
+ def test_wrong_kind(self) -> None:
66
+ self.assertPydanticLiteralError(lambda: PluginSetCatalog(kind='WrongKind'),
67
+ 'kind',
68
+ 'PluginSetCatalog')
69
+
70
+ def test_missing_plugin_registry_files(self) -> None:
71
+ self.assertPydanticMissing(lambda: PluginSetCatalog(),
72
+ 'plugin-set-files')
73
+
74
+ def test_null_plugin_registry_files(self) -> None:
75
+ self.assertPydanticListType(lambda: PluginSetCatalog(**{'plugin-set-files': None}),
76
+ 'plugin-set-files')
77
+
78
+ def test_empty_plugin_registry_files(self) -> None:
79
+ self.assertPydanticTooShort(lambda: PluginSetCatalog(**{'plugin-set-files': []}),
80
+ 'plugin-set-files')
81
+
82
+ def test_uninitialized(self) -> None:
83
+ psc = PluginSetCatalog(**{'kind': 'PluginSetCatalog',
84
+ 'plugin-set-files': ['whatever']})
85
+ self.assertRaises(ValueError, lambda: psc.get_root())
86
+ self.assertRaises(ValueError, lambda: psc.get_plugin_set_files())
41
87
 
42
- def setUp(self):
88
+ def test_kind(self) -> None:
89
+ for valid in self.valid:
90
+ self.assertEqual(valid.kind, 'PluginSetCatalog')
91
+
92
+ def test_get_plugin_set_files(self) -> None:
93
+ self.assertListEqual(self.valid_absolute.get_plugin_set_files(),
94
+ [Path('/tmp/one.yaml')])
95
+ self.assertListEqual(self.valid_relative.get_plugin_set_files(),
96
+ [ROOT.joinpath('one.yaml')])
97
+
98
+
99
+ # Important: see "del _BasePluginSetBuilderTestCase" at the end
100
+ class _BasePluginSetBuilderTestCase(ABC, PydanticTestCase):
101
+
102
+ def setUp(self) -> None:
103
+ super().setUp()
104
+ self.valid_absolute = self.instance(type=self.type(),
105
+ main='/tmp/maindir',
106
+ test='/tmp/testdir').initialize(ROOT)
107
+ self.valid_relative = self.instance(type=self.type(),
108
+ main='maindir',
109
+ test='testdir').initialize(ROOT)
110
+ self.valid = [self.valid_absolute, self.valid_relative]
111
+
112
+ @abstractmethod
113
+ def instance(self, **kwargs) -> BasePluginSetBuilder:
114
+ pass
115
+
116
+ @abstractmethod
117
+ def type(self) -> PluginSetBuilderType:
43
118
  pass
44
119
 
45
- def testPluginSet(self):
46
- self.assertPydanticMissing(lambda: PluginSet(), 'kind')
47
- self.assertPydanticLiteralError(lambda: PluginSet(kind='WrongKind'), 'kind', 'PluginSet')
48
- self.assertPydanticMissing(lambda: PluginSet(kind='PluginSet'), 'id')
49
- self.assertPydanticMissing(lambda: PluginSet(kind='PluginSet', id='myid'), 'name')
50
- self.assertPydanticMissing(lambda: PluginSet(kind='PluginSet', id='myset', name='My Set'), 'builder')
51
- PluginSet(kind='PluginSet', id='myset', name='My Set', builder=AntPluginSetBuilder(type='ant'))
52
- PluginSet(kind='PluginSet', id='myset', name='My Set', builder=MavenPluginSetBuilder(type='maven'))
53
-
54
-
55
- class TestPluginSetBuilder(PydanticTestCase):
56
-
57
- def doTestPluginSetBuilder(self, Pbsc: type(PluginSetBuilder), typ: PluginSetBuilderType, def_main: Path, def_test: Path) -> None:
58
- self.assertPydanticMissing(lambda: Pbsc(), 'type')
59
- self.assertPydanticLiteralError(lambda: Pbsc(type='BADTYPE'), 'type', typ)
60
- self.assertIsNone(Pbsc(type=typ)._root)
61
- with self.assertRaises(ValueError):
62
- Pbsc(type=typ).get_root()
63
- self.assertEqual(Pbsc(type=typ).initialize(ROOT).get_root(), ROOT)
64
- with self.assertRaises(ValueError):
65
- Pbsc(type=typ, main='anything').get_main()
66
- self.assertEqual(Pbsc(type=typ).initialize(ROOT).get_main(), def_main)
67
- self.assertEqual(Pbsc(type=typ, main='mymain').initialize(ROOT).get_main(), ROOT.joinpath('mymain'))
68
- self.assertEqual(Pbsc(type=typ, main='/opt/main').initialize(ROOT).get_main(), Path('/opt/main'))
69
- with self.assertRaises(ValueError):
70
- Pbsc(type=typ, test='anything').get_test()
71
- self.assertEqual(Pbsc(type=typ).initialize(ROOT).get_test(), def_test)
72
- self.assertEqual(Pbsc(type=typ, test='mytest').initialize(ROOT).get_test(), ROOT.joinpath('mytest'))
73
- self.assertEqual(Pbsc(type=typ, test='/opt/test').initialize(ROOT).get_test(), Path('/opt/test'))
74
-
75
- def testPluginSetBuilder(self):
76
- self.doTestPluginSetBuilder(AntPluginSetBuilder, 'ant', ROOT.joinpath('plugins/src'), ROOT.joinpath('plugins/test/src'))
77
- self.doTestPluginSetBuilder(MavenPluginSetBuilder, 'maven', ROOT.joinpath('src/main/java'), ROOT.joinpath('src/test/java'))
120
+ @abstractmethod
121
+ def default_main(self) -> str:
122
+ pass
123
+
124
+ @abstractmethod
125
+ def default_test(self) -> str:
126
+ pass
127
+
128
+ def test_missing_type(self) -> None:
129
+ self.assertPydanticMissing(lambda: self.instance(),
130
+ 'type')
131
+
132
+ def test_null_type(self) -> None:
133
+ self.assertPydanticLiteralError(lambda: self.instance(type=None),
134
+ 'type',
135
+ self.type())
136
+
137
+ def test_default_main(self) -> None:
138
+ self.assertEqual(getattr(self.instance(type=self.type()), '_get_main')(),
139
+ self.default_main())
140
+
141
+ def test_null_main(self) -> None:
142
+ self.assertPydanticStringType(lambda: self.instance(main=None),
143
+ 'main')
144
+
145
+ def test_default_test(self) -> None:
146
+ self.assertEqual(getattr(self.instance(type=self.type()), '_get_test')(),
147
+ self.default_test())
148
+
149
+ def test_null_test(self) -> None:
150
+ self.assertPydanticStringType(lambda: self.instance(test=None),
151
+ 'test')
152
+
153
+ def test_uninitialized(self) -> None:
154
+ psb = self.instance(type=self.type(),
155
+ main='mainpath',
156
+ test='testpath')
157
+ self.assertRaises(ValueError, lambda: psb.get_root())
158
+ self.assertRaises(ValueError, lambda: psb.get_main())
159
+ self.assertRaises(ValueError, lambda: psb.get_test())
160
+
161
+ def test_get_type(self) -> None:
162
+ for valid in self.valid:
163
+ self.assertEqual(valid.get_type(), self.type())
164
+
165
+ def test_get_main(self) -> None:
166
+ self.assertEqual(self.valid_absolute.get_main(), Path('/tmp/maindir'))
167
+ self.assertEqual(self.valid_relative.get_main(), ROOT.joinpath('maindir'))
168
+
169
+ def test_get_test(self) -> None:
170
+ self.assertEqual(self.valid_absolute.get_test(), Path('/tmp/testdir'))
171
+ self.assertEqual(self.valid_relative.get_test(), ROOT.joinpath('testdir'))
172
+
173
+ class TestMavenPluginSetBuilder(_BasePluginSetBuilderTestCase):
174
+
175
+ def instance(self, **kwargs) -> MavenPluginSetBuilder:
176
+ return MavenPluginSetBuilder(**kwargs)
177
+
178
+ def type(self) -> PluginSetBuilderType:
179
+ return 'maven'
180
+
181
+ def default_main(self) -> str:
182
+ return 'src/main/java'
183
+
184
+ def default_test(self) -> str:
185
+ return 'src/test/java'
186
+
187
+
188
+ class TestAntPluginSetBuilder(_BasePluginSetBuilderTestCase):
189
+
190
+ def instance(self, **kwargs) -> AntPluginSetBuilder:
191
+ return AntPluginSetBuilder(**kwargs)
192
+
193
+ def type(self) -> PluginSetBuilderType:
194
+ return 'ant'
195
+
196
+ def default_main(self) -> str:
197
+ return 'plugins/src'
198
+
199
+ def default_test(self) -> str:
200
+ return 'plugins/test/src'
201
+
202
+
203
+ class TestPluginSet(PydanticTestCase):
204
+
205
+ def setUp(self) -> None:
206
+ super().setUp()
207
+ self.valid_builder = MavenPluginSetBuilder(type='maven')
208
+ self.valid = PluginSet(kind='PluginSet',
209
+ id='myid',
210
+ name='My Name',
211
+ builder=self.valid_builder).initialize(ROOT)
212
+
213
+ def test_missing_kind(self) -> None:
214
+ self.assertPydanticMissing(lambda: PluginSet(),
215
+ 'kind')
216
+
217
+ def test_null_kind(self) -> None:
218
+ self.assertPydanticLiteralError(lambda: PluginSet(kind=None),
219
+ 'kind',
220
+ 'PluginSet')
221
+
222
+ def test_wrong_kind(self) -> None:
223
+ self.assertPydanticLiteralError(lambda: PluginSet(kind='WrongKind'),
224
+ 'kind',
225
+ 'PluginSet')
226
+
227
+ def test_missing_identifier(self) -> None:
228
+ self.assertPydanticMissing(lambda: PluginSet(),
229
+ 'id')
230
+
231
+ def test_null_identifier(self) -> None:
232
+ self.assertPydanticStringType(lambda: PluginSet(id=None),
233
+ 'id')
234
+
235
+ def test_missing_name(self) -> None:
236
+ self.assertPydanticMissing(lambda: PluginSet(),
237
+ 'name')
238
+
239
+ def test_null_name(self) -> None:
240
+ self.assertPydanticStringType(lambda: PluginSet(name=None),
241
+ 'name')
242
+
243
+ def test_missing_builder(self) -> None:
244
+ self.assertPydanticMissing(lambda: PluginSet(),
245
+ 'builder')
246
+
247
+ def test_null_builder(self) -> None:
248
+ self.assertPydanticModelAttributesType(lambda: PluginSet(builder=None),
249
+ 'builder')
250
+
251
+ def test_uninitialized(self) -> None:
252
+ ps = PluginSet(kind='PluginSet',
253
+ id='myid',
254
+ name='My Name',
255
+ builder=MavenPluginSetBuilder(type='maven'))
256
+ self.assertRaises(ValueError, lambda: ps.get_builder().get_root())
257
+
258
+ def test_kind(self) -> None:
259
+ self.assertEqual(self.valid.kind, 'PluginSet')
260
+
261
+ def test_get_id(self) -> None:
262
+ self.assertEqual(self.valid.get_id(), 'myid')
263
+
264
+ def test_get_name(self) -> None:
265
+ self.assertEqual(self.valid.get_name(), 'My Name')
266
+
267
+ def test_get_builder(self) -> None:
268
+ self.assertEqual(self.valid.get_builder(), self.valid_builder)
269
+
270
+
271
+ #
272
+ # See https://stackoverflow.com/a/43353680
273
+ #
274
+ del _BasePluginSetBuilderTestCase
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Copyright (c) 2000-2025, Board of Trustees of Leland Stanford Jr. University
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ #
11
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # 3. Neither the name of the copyright holder nor the names of its contributors
16
+ # may be used to endorse or promote products derived from this software without
17
+ # specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ # Remove in Python 3.14
32
+ # See https://stackoverflow.com/questions/33533148/how-do-i-type-hint-a-method-with-the-type-of-the-enclosing-class/33533514#33533514
33
+ from __future__ import annotations
34
+
35
+ from abc import ABC, abstractmethod
36
+ from pathlib import Path
37
+
38
+ from . import PydanticTestCase, ROOT
39
+ from lockss.turtles.plugin_signing_credentials import PluginSigningCredentials
40
+
41
+ class TestPluginSigningCredentials(PydanticTestCase):
42
+
43
+ def setUp(self) -> None:
44
+ super().setUp()
45
+ self.valid_absolute = PluginSigningCredentials(**{'kind': 'PluginSigningCredentials',
46
+ 'plugin-signing-keystore': '/tmp/keystore.txt',
47
+ 'plugin-signing-alias': 'myalias'}).initialize(ROOT)
48
+ self.valid_relative = PluginSigningCredentials(**{'kind': 'PluginSigningCredentials',
49
+ 'plugin-signing-keystore': 'keystore.txt',
50
+ 'plugin-signing-alias': 'myalias'}).initialize(ROOT)
51
+ self.valid = [self.valid_absolute, self.valid_relative]
52
+
53
+ def test_missing_kind(self) -> None:
54
+ self.assertPydanticMissing(lambda: PluginSigningCredentials(),
55
+ 'kind')
56
+
57
+ def test_null_kind(self) -> None:
58
+ self.assertPydanticLiteralError(lambda: PluginSigningCredentials(kind=None),
59
+ 'kind',
60
+ 'PluginSigningCredentials')
61
+
62
+ def test_wrong_kind(self) -> None:
63
+ self.assertPydanticLiteralError(lambda: PluginSigningCredentials(kind='WrongKind'),
64
+ 'kind',
65
+ 'PluginSigningCredentials')
66
+
67
+ def test_missing_plugin_signing_alias(self) -> None:
68
+ self.assertPydanticMissing(lambda: PluginSigningCredentials(),
69
+ 'plugin-signing-alias')
70
+
71
+ def test_null_plugin_signing_alias(self) -> None:
72
+ self.assertPydanticStringType(lambda: PluginSigningCredentials(**{'plugin-signing-alias': None}),
73
+ 'plugin-signing-alias')
74
+
75
+ def test_missing_plugin_signing_keystore(self) -> None:
76
+ self.assertPydanticMissing(lambda: PluginSigningCredentials(),
77
+ 'plugin-signing-keystore')
78
+
79
+ def test_null_plugin_signing_keystore(self) -> None:
80
+ self.assertPydanticStringType(lambda: PluginSigningCredentials(**{'plugin-signing-keystore': None}),
81
+ 'plugin-signing-keystore')
82
+
83
+ def test_uninitialized(self) -> None:
84
+ psc = PluginSigningCredentials(**{'kind': 'PluginSigningCredentials',
85
+ 'plugin-signing-keystore': '/tmp/keystore.txt',
86
+ 'plugin-signing-alias': 'myalias'})
87
+ self.assertRaises(ValueError, lambda: psc.get_root())
88
+ self.assertRaises(ValueError, lambda: psc.get_plugin_signing_keystore())
89
+
90
+ def test_kind(self) -> None:
91
+ for valid in self.valid:
92
+ self.assertEqual(valid.kind, 'PluginSigningCredentials')
93
+
94
+ def test_get_plugin_signing_alias(self) -> None:
95
+ for valid in self.valid:
96
+ self.assertEqual(valid.get_plugin_signing_alias(), 'myalias')
97
+
98
+ def test_get_plugin_signing_keystore(self) -> None:
99
+ self.assertEqual(self.valid_absolute.get_plugin_signing_keystore(),
100
+ Path('/tmp/keystore.txt'))
101
+ self.assertEqual(self.valid_relative.get_plugin_signing_keystore(),
102
+ ROOT.joinpath('keystore.txt'))
@@ -1,15 +0,0 @@
1
- lockss/turtles/__init__.py,sha256=h2gkVQIPx7M4cQT_0ZSSioskUq00IUryPyduZ6g5sV8,1827
2
- lockss/turtles/__main__.py,sha256=BqRTG3dejCgLh87UJ1Os9DD9unxnQkOdUQM6eqWS3Sg,1680
3
- lockss/turtles/app.py,sha256=Rxbsq10A830D1r99a5tqLVYWM3bJZ2Org-JKjXD-2Mk,16689
4
- lockss/turtles/cli.py,sha256=Pgd0GSThxDfnPWKwwujo6ZocfKePoe-aiHJ9qYpm9BQ,21019
5
- lockss/turtles/plugin.py,sha256=HT01Er9-odvJ4lF8DNC7TV4uxSqTw44UBe02Jgj5xMs,11065
6
- lockss/turtles/plugin_registry.py,sha256=UlB9faNH8fEh9mfdj6byMcRcZ7axi0DzUP2qdyj9ANk,26935
7
- lockss/turtles/plugin_set.py,sha256=PuzSWl2k7ikbkKtxStQRJhcXi1JXuSBl9jXz4dzp7Ts,24550
8
- lockss/turtles/util.py,sha256=P-f-Uc4hdrjvaKnyVozwCO8oVpUWJ_YXaxeFDBxwHWM,3658
9
- unittest/lockss/turtles/__init__.py,sha256=hrgWx4GaP-hhPBuRlbLndJnOQmZicKCLaP-dQTCu1sQ,3162
10
- unittest/lockss/turtles/test_plugin_set.py,sha256=q6JmooDR-wijAQ8x9DWKTNB6Of4EOr3Dgq8oaX0LTpQ,4179
11
- lockss_turtles-0.6.0.dev24.dist-info/LICENSE,sha256=O9ONND4uDxY_jucI4jZDf2liAk05ScEJaYu-Al7EOdQ,1506
12
- lockss_turtles-0.6.0.dev24.dist-info/METADATA,sha256=IQceC6i6VxnjA6Dgv4SVYj9BIsdbHQfWrmROxDaeMZg,2340
13
- lockss_turtles-0.6.0.dev24.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
14
- lockss_turtles-0.6.0.dev24.dist-info/entry_points.txt,sha256=25BAVFSBRKWAWiXIGZgcr1ypt2mV7nj31Jl8WcNZZOk,51
15
- lockss_turtles-0.6.0.dev24.dist-info/RECORD,,