-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Summary
The set_maintenance method raises an exception if passed a default-constructed maintenance report.
Issue Type
- Bug Report
Steps to reproduce
Try to set_maintenance with an empty MaintenanceReport. (Note: it can be reproduced with both real and fake clients, so no running Pulp server is needed)
>>> from pubtools.pulplib import FakeController, MaintenanceReport
>>> FakeController().client.set_maintenance(MaintenanceReport()).result()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rmcgover/src/pubtools-pulplib/pubtools/pulplib/_impl/fake/client.py", line 151, in set_maintenance
report_json = json.dumps(report._export_dict(), indent=4, sort_keys=True)
File "/home/rmcgover/src/pubtools-pulplib/pubtools/pulplib/_impl/model/maintenance.py", line 124, in _export_dict
"last_updated": write_timestamp(self.last_updated),
File "/home/rmcgover/src/pubtools-pulplib/pubtools/pulplib/_impl/model/convert.py", line 35, in write_timestamp
return value.strftime("%Y-%m-%dT%H:%M:%SZ")
AttributeError: 'NoneType' object has no attribute 'strftime'
Actual results
Crashes with internal error.
Expected results
Two alternatives:
- (Preferred) the maintenance report is successfully uploaded, with last_updated field automatically initialized to the current date/time.
- The maintenance report is considered invalid, and an exception is raised with a meaningful type & message.
OS / Environment
all
Additional Information
It should not be solved by setting a default last_updated on the MaintenanceReport model, because that means two default-constructed MaintenanceReport aren't equal. It should probably be solved by having a default last_updated during the serialization to dict.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels