blob: 90e3857fce938f139a17cbd483df31abda07fcd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
from pkgcore.package import base, metadata
def make_pkg_kls(attrs=(), callbacks={}):
class simple_pkg(base.base):
_get_attr = callbacks
__slots__ = (
"_args",
"_kwds",
"_data",
"_fetch_called",
) + tuple(attrs)
def __init__(self, *args, **kwds):
self._args = args
self._data = kwds.pop("data", {})
self._kwds = kwds
self._fetch_called = False
__setattr__ = object.__setattr__
class metadata_pkg(metadata.DeriveMetadataKls(simple_pkg)):
__slots__ = ()
def _fetch_metadata(self):
self._fetch_called = True
return self._data
return metadata_pkg
class TestMetadataPackage:
def test_init(self):
class repo:
_parent_repo = "foon"
kls = make_pkg_kls()
o = kls(repo, "monkeys", dar=1)
assert o._parent == repo
assert o.repo == "foon"
assert o._args == ("monkeys",)
assert o._kwds == {"dar": 1}
assert not o._fetch_called
def test_getdata(self):
kls = make_pkg_kls()
o = kls(None, data={"a": "b"})
assert o.data == {"a": "b"}
|