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 ietf-tools#3415
  • Loading branch information
kesara committed Jul 20, 2024
1 parent 02baeef commit bc27442
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 @@ -872,13 +872,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):
url = urlreverse('ietf.api.views.app_auth')
person = PersonFactory()
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 bc27442

Please sign in to comment.