4831: Rearrange mithril-dom as mithril-jquery
[arvados.git] / services / datamanager / experimental / datamanager_test.py
1 #! /usr/bin/env python
2
3 import datamanager
4 import unittest
5
6 class TestComputeWeightedReplicationCosts(unittest.TestCase):
7   def test_obvious(self):
8     self.assertEqual(datamanager.computeWeightedReplicationCosts([1,]),
9                      {1:1.0})
10
11   def test_simple(self):
12     self.assertEqual(datamanager.computeWeightedReplicationCosts([2,]),
13                      {2:2.0})
14
15   def test_even_split(self):
16     self.assertEqual(datamanager.computeWeightedReplicationCosts([1,1]),
17                      {1:0.5})
18
19   def test_even_split_bigger(self):
20     self.assertEqual(datamanager.computeWeightedReplicationCosts([2,2]),
21                      {2:1.0})
22
23   def test_uneven_split(self):
24     self.assertEqual(datamanager.computeWeightedReplicationCosts([1,2]),
25                      {1:0.5, 2:1.5})
26
27   def test_uneven_split_bigger(self):
28     self.assertEqual(datamanager.computeWeightedReplicationCosts([1,3]),
29                      {1:0.5, 3:2.5})
30
31   def test_uneven_split_jumble(self):
32     self.assertEqual(datamanager.computeWeightedReplicationCosts([1,3,6,6,10]),
33                      {1:0.2, 3:0.7, 6:1.7, 10:5.7})
34
35   def test_documentation_example(self):
36     self.assertEqual(datamanager.computeWeightedReplicationCosts([1,1,3,6,6]),
37                      {1:0.2, 3: 0.2 + 2.0 / 3, 6: 0.2 + 2.0 / 3 + 1.5})
38
39
40 if __name__ == '__main__':
41   unittest.main()