File: test_billing.py

package info (click to toggle)
pontos 25.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,744 kB
  • sloc: python: 44,602; makefile: 21; sh: 10; xml: 3
file content (66 lines) | stat: -rw-r--r-- 2,202 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# SPDX-FileCopyrightText: 2023 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later

# ruff: noqa:E501

import unittest

from pontos.github.models.billing import (
    ActionsBilling,
    PackagesBilling,
    StorageBilling,
)


class ActionsBillingTestCase(unittest.TestCase):
    def test_from_dict(self):
        billing = ActionsBilling.from_dict(
            {
                "total_minutes_used": 305,
                "total_paid_minutes_used": 0,
                "included_minutes": 3000,
                "minutes_used_breakdown": {
                    "UBUNTU": 205,
                    "MACOS": 10,
                    "WINDOWS": 90,
                },
            }
        )

        self.assertEqual(billing.total_minutes_used, 305)
        self.assertEqual(billing.total_paid_minutes_used, 0)
        self.assertEqual(billing.included_minutes, 3000)
        self.assertEqual(billing.minutes_used_breakdown.UBUNTU, 205)
        self.assertEqual(billing.minutes_used_breakdown.MACOS, 10)
        self.assertEqual(billing.minutes_used_breakdown.WINDOWS, 90)
        self.assertIsNone(billing.minutes_used_breakdown.total)


class PackagesBillingTestCase(unittest.TestCase):
    def test_from_dict(self):
        billing = PackagesBilling.from_dict(
            {
                "total_gigabytes_bandwidth_used": 50,
                "total_paid_gigabytes_bandwidth_used": 40,
                "included_gigabytes_bandwidth": 10,
            }
        )

        self.assertEqual(billing.total_gigabytes_bandwidth_used, 50)
        self.assertEqual(billing.total_paid_gigabytes_bandwidth_used, 40)
        self.assertEqual(billing.included_gigabytes_bandwidth, 10)


class StorageBillingTestCase(unittest.TestCase):
    def test_from_dict(self):
        billing = StorageBilling.from_dict(
            {
                "days_left_in_billing_cycle": 20,
                "estimated_paid_storage_for_month": 15,
                "estimated_storage_for_month": 40,
            }
        )
        self.assertEqual(billing.days_left_in_billing_cycle, 20)
        self.assertEqual(billing.estimated_paid_storage_for_month, 15)
        self.assertEqual(billing.estimated_storage_for_month, 40)