Ejemplo n.º 1
0
    def test_fill_in_missing_units_list(self):
        """Test that missing units are filled in."""
        expected_unit = 'Hrs'
        data = [{
            'date': '2018-07-22',
            'units': '',
            'instance_type': 't2.micro',
            'total': 30.0,
            'count': 0
        }, {
            'date': '2018-07-22',
            'units': expected_unit,
            'instance_type': 't2.small',
            'total': 17.0,
            'count': 0
        }, {
            'date': '2018-07-22',
            'units': expected_unit,
            'instance_type': 't2.micro',
            'total': 1.0,
            'count': 0
        }]

        unit = _find_unit()(data)

        result = _fill_in_missing_units(unit)(data)

        for entry in result:
            self.assertEqual(entry.get('units'), expected_unit)
Ejemplo n.º 2
0
    def test_find_unit_list(self):
        """Test that the correct unit is returned."""
        expected_unit = 'Hrs'
        data = [{
            'date': '2018-07-22',
            'units': '',
            'instance_type': 't2.micro',
            'total': 30.0,
            'count': 0
        }, {
            'date': '2018-07-22',
            'units': expected_unit,
            'instance_type': 't2.small',
            'total': 17.0,
            'count': 0
        }, {
            'date': '2018-07-22',
            'units': expected_unit,
            'instance_type': 't2.micro',
            'total': 1.0,
            'count': 0
        }]

        result_unit = _find_unit()(data)
        self.assertEqual(expected_unit, result_unit)
Ejemplo n.º 3
0
    def test_find_unit_dict(self):
        """Test that the correct unit is returned for a dictionary."""
        data = {'date': '2018-07-22', 'units': '',
                'instance_type': 'Standard_A1_v2', 'total': 30.0, 'count': 0},

        result_unit = _find_unit()(data)
        self.assertIsNone(result_unit)
Ejemplo n.º 4
0
 def test_fill_in_missing_units_list(self):
     """Test that missing units are filled in."""
     expected_unit = "Hrs"
     data = [
         # AWS
         {"date": "2018-07-22", "units": "", "instance_type": "t2.micro", "total": 30.0, "count": 0},
         {"date": "2018-07-22", "units": expected_unit, "instance_type": "t2.small", "total": 17.0, "count": 0},
         {"date": "2018-07-22", "units": expected_unit, "instance_type": "t2.micro", "total": 1.0, "count": 0},
         # Azure
         {"date": "2018-07-22", "units": "", "instance_type": "Standard_A1_v2", "total": 30.0, "count": 0},
         {
             "date": "2018-07-22",
             "units": expected_unit,
             "instance_type": "Standard_A2m_v2",
             "total": 17.0,
             "count": 0,
         },  # noqa: E501
         {
             "date": "2018-07-22",
             "units": expected_unit,
             "instance_type": "Standard_A1_v2",
             "total": 1.0,
             "count": 0,
         },
     ]
     unit = _find_unit()(data)
     result = _fill_in_missing_units(unit)(data)
     for entry in result:
         self.assertEqual(entry.get("units"), expected_unit)
Ejemplo n.º 5
0
 def test_find_unit_list(self):
     """Test that the correct unit is returned."""
     expected_unit = "Hrs"
     data = [
         {
             "date": "2018-07-22",
             "units": "",
             "instance_type": "t2.micro",
             "total": 30.0,
             "count": 0
         },
         {
             "date": "2018-07-22",
             "units": expected_unit,
             "instance_type": "t2.small",
             "total": 17.0,
             "count": 0
         },
         {
             "date": "2018-07-22",
             "units": expected_unit,
             "instance_type": "t2.micro",
             "total": 1.0,
             "count": 0
         },
     ]
     result_unit = _find_unit()(data)
     self.assertEqual(expected_unit, result_unit)
Ejemplo n.º 6
0
 def test_find_unit_dict(self):
     """Test that the correct unit is returned for a dictionary."""
     data = {
         "date": "2018-07-22",
         "units": "",
         "instance_type": "t2.micro",
         "total": 30.0,
         "count": 0
     }
     result_unit = _find_unit()(data)
     self.assertIsNone(result_unit)