File: disable_test_mgmt_billing.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (97 lines) | stat: -rw-r--r-- 4,135 bytes parent folder | download | duplicates (3)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# coding: utf-8

#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
import unittest

import azure.mgmt.billing
from devtools_testutils import AzureMgmtTestCase

class MgmtBillingTest(AzureMgmtTestCase):

    def _validate_invoice(self, invoice, url_generated=False):
        self.assertIsNotNone(invoice)
        self.assertIsNotNone(invoice.id)
        self.assertIsNotNone(invoice.name)
        self.assertIsNotNone(invoice.type)
        self.assertTrue(len(invoice.billing_period_ids) > 0)
        self.assertTrue(invoice.invoice_period_start_date <= invoice.invoice_period_end_date)
        if url_generated:
            self.assertIsNotNone(invoice.download_url.url)
            self.assertIsNotNone(invoice.download_url.expiry_time)
        else:
            self.assertIsNone(invoice.download_url)

    def _validate_billing_period(self, billing_period):
        self.assertIsNotNone(billing_period)
        self.assertIsNotNone(billing_period.id)
        self.assertIsNotNone(billing_period.name)
        self.assertIsNotNone(billing_period.type)
        self.assertTrue(billing_period.billing_period_start_date <= billing_period.billing_period_end_date)

    def setUp(self):
        super(MgmtBillingTest, self).setUp()
        self.billing_client = self.create_mgmt_client(azure.mgmt.billing.BillingManagementClient)

    @unittest.skip("skip")
    def test_billing_enrollment_accounts_list(self):
        output = list(self.billing_client.enrollment_accounts.list())
        self.assertTrue(len(output) > 0)

    @unittest.skip("skip")
    def test_billing_invoice_latest(self):
        output = self.billing_client.invoices.get_latest()
        self._validate_invoice(output, url_generated=True)

    @unittest.skip("skip")
    def test_billing_invoice_list_get(self):
        output = list(self.billing_client.invoices.list())
        self.assertTrue(len(output) > 0)
        self._validate_invoice(output[0], url_generated=False)
        invoice = self.billing_client.invoices.get(output[0].name)
        self._validate_invoice(invoice, url_generated=True)

    @unittest.skip("skip")
    def test_billing_invoice_list_generate_url(self):
        output = list(self.billing_client.invoices.list(expand='downloadUrl'))
        self.assertTrue(len(output) > 0)
        self._validate_invoice(output[0], url_generated=True)

    @unittest.skip("skip")
    def test_billing_invoice_list_top(self):
        output = list(self.billing_client.invoices.list(expand='downloadUrl', top=1))
        self.assertEqual(1, len(output))
        self._validate_invoice(output[0], url_generated=True)

    @unittest.skip("skip")
    def test_billing_invoice_list_filter(self):
        output = list(self.billing_client.invoices.list(filter='invoicePeriodEndDate gt 2017-02-01'))
        self.assertTrue(len(output) > 0)
        self._validate_invoice(output[0], url_generated=False)

    @unittest.skip("skip")
    def test_billing_period_list_get(self):
        output = list(self.billing_client.billing_periods.list())
        self.assertTrue(len(output) > 0)
        self._validate_billing_period(output[0])
        billing_period = self.billing_client.billing_periods.get(output[0].name)
        self._validate_billing_period(billing_period)

    @unittest.skip("skip")
    def test_billing_period_list_top(self):
        output = list(self.billing_client.billing_periods.list(top=1))
        self.assertEqual(1, len(output))
        self._validate_billing_period(output[0])

    @unittest.skip("skip")
    def test_billing_period_list_filter(self):
        output = list(self.billing_client.billing_periods.list(filter='billingPeriodEndDate gt 2017-02-01'))
        self.assertTrue(len(output) > 0)
        self._validate_billing_period(output[0])

#------------------------------------------------------------------------------
if __name__ == '__main__':
    unittest.main()