-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Tests for ``xentica.utils`` module.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
"""Tests for ``xentica.utils.formatters`` module.""" | ||
import unittest | ||
|
||
from xentica.utils.formatters import sizeof_fmt | ||
|
||
|
||
class TestSizeFormatter(unittest.TestCase): | ||
"""Tests for size formatter helper.""" | ||
|
||
def test_less_kilo(self): | ||
"""Test less than Kilo rendering as plain values.""" | ||
val = sizeof_fmt(345) | ||
self.assertEqual(val, "345", "Less Kilo format is incorrect.") | ||
|
||
def test_kilo(self): | ||
"""Test numbers between 10e3 and 10e6 has K postix.""" | ||
val = sizeof_fmt(34567) | ||
self.assertEqual(val, "34.57K", "Kilo format is incorrect.") | ||
|
||
def test_peta(self): | ||
"""Test numbers between 10e15 and 10e18 has P postix.""" | ||
val = sizeof_fmt(34567 * (10 ** 12)) | ||
self.assertEqual(val, "34.57P", "Peta format is incorrect.") | ||
|
||
def test_yokta(self): | ||
"""Test numbers larger than 10e24 has Y postix.""" | ||
val = sizeof_fmt(34567 * (10 ** 21)) | ||
self.assertEqual(val, "34.57Y", "Yokta format is incorrect.") |