File: test_billing.py

package info (click to toggle)
python-duo-client 5.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 768 kB
  • sloc: python: 7,105; sh: 6; makefile: 4
file content (75 lines) | stat: -rw-r--r-- 2,709 bytes parent folder | download
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
import json

from .. import util
import duo_client.admin
from .base import TestAccountAdmin


class TestBilling(TestAccountAdmin):
    def test_get_billing_edition(self):
        """Test to get billing edition
        """
        response = self.client.get_edition()
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(uri, '/admin/v1/billing/edition')
        self.assertEqual(util.params_to_dict(args),
                         {
                             'account_id': [self.client.account_id],
                         })

    def test_set_business_billing_edition(self):
        """Test to set PLATFORM billing edition
        """
        response = self.client.set_edition('PLATFORM')
        uri = response['uri']

        self.assertEqual(response['method'], 'POST')
        self.assertEqual(uri, '/admin/v1/billing/edition')
        self.assertEqual(json.loads(response['body']),
                         {
                             'edition': 'PLATFORM',
                             'account_id': self.client.account_id,
                         })

    def test_set_enterprise_billing_edition(self):
        """Test to set ENTERPRISE billing edition
        """
        response = self.client.set_edition('ENTERPRISE')
        uri = response['uri']

        self.assertEqual(response['method'], 'POST')
        self.assertEqual(uri, '/admin/v1/billing/edition')
        self.assertEqual(json.loads(response['body']),
                         {
                             'edition': 'ENTERPRISE',
                             'account_id': self.client.account_id,
                         })

    def test_get_telephony_credits(self):
        """Test to get telephony credits
        """
        response = self.client.get_telephony_credits()
        uri, args = response['uri'].split('?')

        self.assertEqual(response['method'], 'GET')
        self.assertEqual(uri, '/admin/v1/billing/telephony_credits')
        self.assertEqual(util.params_to_dict(args),
                         {
                             'account_id': [self.client.account_id],
                         })

    def test_set_telephony_credits(self):
        """Test to set telephony credits
        """
        response = self.client.set_telephony_credits(10)
        uri = response['uri']

        self.assertEqual(response['method'], 'POST')
        self.assertEqual(uri, '/admin/v1/billing/telephony_credits')
        self.assertEqual(json.loads(response['body']),
                         {
                             'credits': '10',
                             'account_id': self.client.account_id,
                         })