forked from erp-dev/erp
feat: app verion && some field modify (printing & shipment)
This commit is contained in:
@@ -3,6 +3,7 @@ from io import StringIO
|
||||
from django.core.cache import cache
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase, override_settings
|
||||
from django.utils import timezone
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from flower.app_version import APP_VERSION_CACHE_KEY
|
||||
@@ -21,6 +22,8 @@ class AppVersionAPITest(TestCase):
|
||||
APP_LATEST_VERSION_MINOR=2,
|
||||
APP_LATEST_VERSION_BUILD=345,
|
||||
APP_DOWNLOAD_URL="https://example.com/app.apk",
|
||||
APP_FORCE_UPDATE=True,
|
||||
APP_PUBLISH_DATE="2026-07-08",
|
||||
)
|
||||
def test_app_version_api_returns_settings_payload_without_auth(self):
|
||||
response = self.client.get("/api/app-version/")
|
||||
@@ -35,10 +38,12 @@ class AppVersionAPITest(TestCase):
|
||||
"build": 345,
|
||||
},
|
||||
"download_url": "https://example.com/app.apk",
|
||||
"force": True,
|
||||
"publish_date": "2026-07-08",
|
||||
},
|
||||
)
|
||||
|
||||
def test_set_app_version_command_updates_cached_api_payload(self):
|
||||
def test_set_app_version_command_updates_cached_api_payload_with_defaults(self):
|
||||
output = StringIO()
|
||||
call_command(
|
||||
"set_app_version",
|
||||
@@ -58,4 +63,32 @@ class AppVersionAPITest(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data["latest_version"], {"major": 2, "minor": 5, "build": 1001})
|
||||
self.assertEqual(response.data["download_url"], "https://example.com/latest.apk")
|
||||
self.assertEqual(response.data["force"], False)
|
||||
self.assertEqual(response.data["publish_date"], timezone.localdate().isoformat())
|
||||
self.assertIn("'build': 1001", output.getvalue())
|
||||
|
||||
def test_set_app_version_command_accepts_force_and_publish_date(self):
|
||||
output = StringIO()
|
||||
call_command(
|
||||
"set_app_version",
|
||||
"--major",
|
||||
"2",
|
||||
"--minor",
|
||||
"6",
|
||||
"--build",
|
||||
"1002",
|
||||
"--download-url",
|
||||
"https://example.com/force.apk",
|
||||
"--force",
|
||||
"--publish-date",
|
||||
"2026-07-01",
|
||||
stdout=output,
|
||||
)
|
||||
|
||||
response = self.client.get("/api/app-version/")
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data["latest_version"], {"major": 2, "minor": 6, "build": 1002})
|
||||
self.assertEqual(response.data["download_url"], "https://example.com/force.apk")
|
||||
self.assertEqual(response.data["force"], True)
|
||||
self.assertEqual(response.data["publish_date"], "2026-07-01")
|
||||
|
||||
Reference in New Issue
Block a user