Skip to content

Commit

Permalink
feat: Expose important library versions
Browse files Browse the repository at this point in the history
Update `/api/version` to include

```
"other": {
    "xml2rfc": "<version>",
    "weasyprint": "<version>"
},
```

Fixes #3415
  • Loading branch information
kesara committed Nov 3, 2024
1 parent 1b4f481 commit 256f11d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ietf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@
__release_branch__ = branch
__release_hash__ = git_hash

# important libraries
__version_extra__ = {}
# xml2rfc
try:
import xml2rfc
__version_extra__['xml2rfc'] = xml2rfc.__version__
except Exception:
pass

# weasyprint
try:
import weasyprint
__version_extra__['weasyprint'] = weasyprint.__version__
except Exception:
pass

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
Expand Down
3 changes: 3 additions & 0 deletions ietf/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,13 +936,16 @@ def test_api_version(self):
r = self.client.get(url)
data = r.json()
self.assertEqual(data['version'], ietf.__version__+ietf.__patch__)
self.assertEqual(data['other']['xml2rfc'], ietf.__version_extra__['xml2rfc'])
self.assertEqual(data['other']['weasyprint'], ietf.__version_extra__['weasyprint'])
self.assertEqual(data['dumptime'], "2022-08-31 07:10:01 +0000")
DumpInfo.objects.update(tz='PST8PDT')
r = self.client.get(url)
data = r.json()
self.assertEqual(data['dumptime'], "2022-08-31 07:10:01 -0700")



def test_api_appauth(self):
for app in ["authortools", "bibxml"]:
url = urlreverse('ietf.api.views.app_auth', kwargs={"app": app})
Expand Down
1 change: 1 addition & 0 deletions ietf/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def version(request):
return HttpResponse(
json.dumps({
'version': ietf.__version__+ietf.__patch__,
'other': ietf.__version_extra__,
'dumptime': dumptime,
}),
content_type='application/json',
Expand Down

0 comments on commit 256f11d

Please sign in to comment.