1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +00:00

fix(ui): host and VM charts give their points the panel's time

A host's charts and their "Updated at" line took their times from
timezone.now(), which is UTC, while a VM's charts took time.strftime(),
the panel's time zone. With TIME_ZONE=Europe/Istanbul the same moment
read 09:00 on the host page and 12:00 on the VM page. Both now give the
panel's time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-10 11:53:40 +03:00
parent a8f7c8aeaa
commit 0d20d07b29
4 changed files with 19 additions and 6 deletions

View file

@ -2,6 +2,7 @@
its compute; the next poll sends it back so that the rates are averages since
then, without waiting."""
from datetime import datetime, timezone as dt_timezone
import json
import shutil
import subprocess
@ -13,7 +14,7 @@ from computes.models import Compute
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core import signing
from django.test import TestCase
from django.test import TestCase, override_settings
from django.urls import reverse
from lxml import html
from instances.models import Instance
@ -63,6 +64,11 @@ class StatsViewTestCase(TestCase):
self.stats(sample=data["sample"])
self.assertEqual(self.previous(), SAMPLE)
@override_settings(TIME_ZONE="Europe/Istanbul")
def test_the_time_of_a_point_is_the_panels(self):
with patch("django.utils.timezone.now", return_value=datetime(2026, 11, 10, 9, 0, tzinfo=dt_timezone.utc)):
self.assertEqual(self.stats()["timeline"], "12:00:00")
def test_an_altered_old_or_foreign_sample_is_not_used(self):
token = self.stats()["sample"]
foreign = self.stats(self.other)["sample"]