Skip to content

Commit 89488f9

Browse files
committedDec 2, 2024·
Get unit tests into passing state
1 parent 6352bbe commit 89488f9

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed
 

‎manifester/manifester.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ def create_subscription_allocation(self):
170170
cmd_kwargs=allocation_data,
171171
).json()
172172
logger.debug(f"Received response {self.allocation} when attempting to create allocation.")
173-
self.allocation_uuid = self.allocation["body"]["uuid"]
173+
self.allocation_uuid = (
174+
self.allocation.uuid if self.is_mock else self.allocation["body"]["uuid"]
175+
)
174176
if self.simple_content_access == "disabled":
175177
simple_retry(
176178
self.requester.put,
@@ -196,8 +198,6 @@ def delete_subscription_allocation(self, uuid=None):
196198
"proxies": self.manifest_data.get("proxies"),
197199
"params": {"force": "true"},
198200
}
199-
if self.is_mock:
200-
self.allocation_uuid = self.allocation_uuid.uuid
201201
response = simple_retry(
202202
self.requester.delete,
203203
cmd_args=[f"{self.allocations_url}/{uuid if uuid else self.allocation_uuid}"],
@@ -407,10 +407,7 @@ def trigger_manifest_export(self):
407407
local_file.write_bytes(manifest.content)
408408
manifest.path = local_file
409409
manifest.name = self.manifest_name
410-
if self.is_mock:
411-
manifest.uuid = self.allocation_uuid.uuid
412-
else:
413-
manifest.uuid = self.allocation_uuid
410+
manifest.uuid = self.allocation_uuid
414411
update_inventory(self.subscription_allocations, uuid=self.allocation_uuid)
415412
return manifest
416413

‎tests/test_manifester.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@
8282
+ "".join(random.choices(string.ascii_letters, k=8)),
8383
"type": "Satellite",
8484
"version": f"{MANIFEST_DATA['sat_version']}",
85-
"entitlementQuantity": sum(d["quantity"] for d in MANIFEST_DATA["subscription_data"]),
86-
"url": f"{MANIFEST_DATA['url']['allocations']}/{SUB_ALLOCATION_UUID}",
85+
"entitlementsAttachedQuantity": sum(
86+
d["quantity"] for d in MANIFEST_DATA["subscription_data"]
87+
),
8788
"simpleContentAccess": f"{MANIFEST_DATA['simple_content_access']}",
8889
}
89-
]
90+
],
91+
"status_code": 200,
9092
}
9193

9294

@@ -148,9 +150,9 @@ def get(self, *args, **kwargs):
148150
self.pool_response["body"] += SUB_POOL_RESPONSE["body"]
149151
return self
150152
if args[0].endswith("allocations") and self._has_offset:
151-
if kwargs["params"]["offset"] != 50:
153+
if kwargs["params"]["offset"] != 100:
152154
self.allocations_response = {"body": []}
153-
for _x in range(50):
155+
for _x in range(100):
154156
self.allocations_response["body"].append(
155157
{
156158
"uuid": f"{uuid.uuid4().hex}",
@@ -197,6 +199,15 @@ def delete(self, *args, **kwargs):
197199
self._good_codes = [204]
198200
return self
199201

202+
def __repr__(self):
203+
"""Return a string representation of the RhsmApiStub instance."""
204+
inner = ", ".join(
205+
f"{k}={v}"
206+
for k, v in self.__dict__.items()
207+
if not k.startswith("_") and not callable(v)
208+
)
209+
return f"{self.__class__.__name__}({inner})"
210+
200211

201212
def test_basic_init():
202213
"""Test that manifester can initialize with the minimum required arguments."""
@@ -211,7 +222,7 @@ def test_create_allocation():
211222
"""Test that manifester's create_subscription_allocation method returns a UUID."""
212223
manifester = Manifester(manifest_category=MANIFEST_DATA, requester=RhsmApiStub(in_dict=None))
213224
allocation_uuid = manifester.create_subscription_allocation()
214-
assert allocation_uuid.uuid == SUB_ALLOCATION_UUID
225+
assert allocation_uuid == SUB_ALLOCATION_UUID
215226

216227

217228
def test_negative_simple_retry_timeout():
@@ -300,7 +311,7 @@ def test_invalid_sat_version():
300311
def test_update_inventory():
301312
"""Test that inventory file is populated with expected contents after updating."""
302313
manifester = Manifester(manifest_category=MANIFEST_DATA, requester=RhsmApiStub(in_dict=None))
303-
update_inventory(manifester.subscription_allocations)
314+
update_inventory(manifester.subscription_allocations, sync=True, uuid=SUB_ALLOCATION_UUID)
304315
assert (
305316
load_inventory_file(Path(MANIFEST_DATA["inventory_path"]))
306317
== SUB_ALLOCATIONS_RESPONSE["body"]

0 commit comments

Comments
 (0)
Please sign in to comment.