File: disable_test_mgmt_scheduler.py

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (103 lines) | stat: -rw-r--r-- 3,609 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# 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.
#--------------------------------------------------------------------------
from datetime import timedelta
import unittest

import azure.mgmt.scheduler.models
import azure.mgmt.scheduler.patch

from devtools_testutils import (
    AzureMgmtRecordedTestCase, ResourceGroupPreparer, recorded_by_proxy
)

class TestMgmtScheduler(AzureMgmtRecordedTestCase):

    def setup_method(self, method):
        self.scheduler_client = self.create_mgmt_client(
            azure.mgmt.scheduler.SchedulerManagementClient
        )

    @ResourceGroupPreparer()
    @recorded_by_proxy
    def test_scheduler(self, resource_group, location):
        jobcollection_name = "myjobcollection"
        self.scheduler_client.job_collections.create_or_update(
            resource_group.name,
            jobcollection_name,
            azure.mgmt.scheduler.models.JobCollectionDefinition(
                location=location,
                properties=azure.mgmt.scheduler.models.JobCollectionProperties(
                    sku=azure.mgmt.scheduler.models.Sku(name="Free")
                )
            )
        )

        result = self.scheduler_client.job_collections.get(
            resource_group.name, 
            jobcollection_name,
        )
        assert result.name == jobcollection_name

    @unittest.skip("(BadRequest) Malformed Job Object")
    @ResourceGroupPreparer()
    @recorded_by_proxy
    def test_scheduler_job_custom_time(self, resource_group, location):
        jobcollection_name = "myjobcollection"
        self.scheduler_client.job_collections.create_or_update(
            resource_group.name,
            jobcollection_name,
            azure.mgmt.scheduler.models.JobCollectionDefinition(
                location=location,
                properties=azure.mgmt.scheduler.models.JobCollectionProperties(
                    sku=azure.mgmt.scheduler.models.Sku(name="Free")
                )
            )
        )

        job_properties = azure.mgmt.scheduler.models.JobProperties.from_dict(
            {
                "action": {
                    "request": {
                        "uri": "http://example.org",
                        "method": "GET"
                    },
                    "type": "HTTP",
                    "retry_policy": {
                        "retry_type": "fixed",
                        "retry_interval": timedelta(days=1),
                        "retry_count": 4
                    },
                },
                "recurrence": {
                    "frequency": "hour",
                    "end_time": "2017-09-10T18:50:16.905Z",
                    "interval": 10
                },
                "state": "Disabled"
            }
        )
        assert job_properties.action.retry_policy.retry_interval == timedelta(days=1)

        job_name = "myjob"
        self.scheduler_client.jobs.create_or_update(
            resource_group.name,
            jobcollection_name,
            job_name,
            job_properties
        )

        job = self.scheduler_client.jobs.get(
            resource_group.name,
            jobcollection_name,
            job_name
        )
        assert job.properties.action.retry_policy.retry_interval == timedelta(days=1)

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