Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- n/a
### Fixed
- Fixed a bug that export an empty maintenance report would crash.

## [2.3.1] - 2019-10-03

Expand Down
3 changes: 3 additions & 0 deletions pubtools/pulplib/_impl/model/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ def read_timestamp(value):


def write_timestamp(value):
# defaults to current time if value is None
if value is None:
value = datetime.datetime.utcnow()
return value.strftime("%Y-%m-%dT%H:%M:%SZ")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_requirements():

setup(
name="pubtools-pulplib",
version="2.3.1",
version="2.3.2",
packages=find_packages(exclude=["tests"]),
package_data={"pubtools.pulplib._impl.schema": ["*.yaml"]},
url="https://github.com/release-engineering/pubtools-pulplib",
Expand Down
15 changes: 13 additions & 2 deletions tests/maintenance/test_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_load_invalid_report_raise_exception():

def test_create_export_report():
data = {
"last_updated": "2019-08-15T14:21:12Z", # invalid timestamp
"last_updated": "2019-08-15T14:21:12Z",
"last_updated_by": "pubtools.pulplib",
"repos": {
"repo1": {
Expand All @@ -70,7 +70,7 @@ def test_create_export_report():

def test_report_add_remove():
data = {
"last_updated": "2019-08-15T14:21:12Z", # invalid timestamp
"last_updated": "2019-08-15T14:21:12Z",
"last_updated_by": "pubtools.pulplib",
"repos": {
"repo1": {
Expand All @@ -92,3 +92,14 @@ def test_report_add_remove():

assert len(report.entries) == 1
assert report.last_updated_by == "jazhang"


def test_export_empty_report():
# create an empty report with out data passed
report = MaintenanceReport()
assert report.last_updated is None

# export empty report shouldn't have problem
data = report._export_dict()
# exported report should have a timestamp
assert datetime.datetime.strptime(data["last_updated"], "%Y-%m-%dT%H:%M:%SZ")