mirror of
https://github.com/omaha-consulting/winget.pro.git
synced 2026-10-25 05:09:40 +00:00
Implement api/information
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'api'
|
||||
@@ -0,0 +1,15 @@
|
||||
from django.test import TestCase, Client
|
||||
from django.urls import reverse
|
||||
|
||||
class APITest(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.client = Client()
|
||||
def test_information_required_parts(self):
|
||||
response = self.client.get(reverse('api:information'))
|
||||
data = response.json()['Data']
|
||||
self.assertEqual(
|
||||
'github.com/omaha-consulting/winget-private-repository',
|
||||
data['SourceIdentifier']
|
||||
)
|
||||
self.assertEqual(data['ServerSupportedVersions'], ['1.1.0'])
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = 'api'
|
||||
|
||||
urlpatterns = [
|
||||
path('information', views.information, name='information')
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.http import JsonResponse
|
||||
|
||||
def information(request):
|
||||
return JsonResponse({
|
||||
'Data': {
|
||||
'SourceIdentifier': 'github.com/omaha-consulting/winget-private-repository',
|
||||
'ServerSupportedVersions': ['1.1.0']
|
||||
}
|
||||
})
|
||||
@@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'api'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
+3
-17
@@ -1,21 +1,7 @@
|
||||
"""wpr URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/4.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import include, path
|
||||
|
||||
urlpatterns = [
|
||||
path('api/', include('api.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user