tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

data_points_unittests.py (1142B)


      1 #!/usr/bin/env vpython3
      2 
      3 # Copyright 2024 The Chromium Authors
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 """File for testing data_points.py."""
      7 
      8 import unittest
      9 from data_points import DataPoints
     10 
     11 
     12 class DataPointsTest(unittest.TestCase):
     13  """Test data_points.py."""
     14 
     15  def test_no_record(self) -> None:
     16    points = DataPoints("a")
     17    self.assertEqual(points.dump().name, "a")
     18    self.assertEqual(len(points.dump().points.points), 0)
     19 
     20  def test_one_record(self) -> None:
     21    points = DataPoints("b")
     22    points.record(101)
     23    self.assertEqual(points.dump().name, "b")
     24    self.assertEqual(len(points.dump().points.points), 1)
     25    self.assertEqual(points.dump().points.points[0].value, 101)
     26 
     27  def test_more_records(self) -> None:
     28    points = DataPoints("c")
     29    points.record(1)
     30    points.record(2)
     31    self.assertEqual(points.dump().name, "c")
     32    self.assertEqual(len(points.dump().points.points), 2)
     33    self.assertEqual(points.dump().points.points[0].value, 1)
     34    self.assertEqual(points.dump().points.points[1].value, 2)
     35 
     36 
     37 if __name__ == '__main__':
     38  unittest.main()