Przeglądaj źródła

#8232: Cleanup & test fix

jeremystretch 3 lat temu
rodzic
commit
dde4495e20

+ 2 - 2
netbox/ipam/tests/test_models.py

@@ -204,11 +204,11 @@ class TestPrefix(TestCase):
         IPAddress.objects.bulk_create([
         IPAddress.objects.bulk_create([
             IPAddress(address=IPNetwork(f'10.0.0.{i}/24')) for i in range(1, 33)
             IPAddress(address=IPNetwork(f'10.0.0.{i}/24')) for i in range(1, 33)
         ])
         ])
-        self.assertEqual(prefix.get_utilization(), 12)  # 12.5% utilization
+        self.assertEqual(prefix.get_utilization(), 32 / 254 * 100)  # ~12.5% utilization
 
 
         # Create a child range with 32 additional IPs
         # Create a child range with 32 additional IPs
         IPRange.objects.create(start_address=IPNetwork('10.0.0.33/24'), end_address=IPNetwork('10.0.0.64/24'))
         IPRange.objects.create(start_address=IPNetwork('10.0.0.33/24'), end_address=IPNetwork('10.0.0.64/24'))
-        self.assertEqual(prefix.get_utilization(), 25)  # 25% utilization
+        self.assertEqual(prefix.get_utilization(), 64 / 254 * 100)  # ~25% utilization
 
 
     #
     #
     # Uniqueness enforcement tests
     # Uniqueness enforcement tests

+ 2 - 2
netbox/utilities/templates/helpers/utilization_graph.html

@@ -12,10 +12,10 @@
       class="progress-bar {{ bar_class }}"
       class="progress-bar {{ bar_class }}"
       style="width: {{ utilization }}%;"
       style="width: {{ utilization }}%;"
     >
     >
-      {% if utilization >= 25 %}{{ utilization|floatformat:-2 }}%{% endif %}
+      {% if utilization >= 25 %}{{ utilization|floatformat:0 }}%{% endif %}
     </div>
     </div>
     {% if utilization < 25 %}
     {% if utilization < 25 %}
-      <span class="ps-1">{{ utilization|floatformat:-2 }}%</span>
+      <span class="ps-1">{{ utilization|floatformat:0 }}%</span>
     {% endif %}
     {% endif %}
   </div>
   </div>
 {% endif %}
 {% endif %}