Ejemplo n.º 1
0
    def set_service_properties(self, queue_service):

        try:
            print('1. Get Queue service properties')
            props = queue_service.get_queue_service_properties()

            retention = RetentionPolicy(enabled=True, days=5)
            logging = Logging(delete=True,
                              read=False,
                              write=True,
                              retention_policy=retention)
            hour_metrics = Metrics(enabled=True,
                                   include_apis=True,
                                   retention_policy=retention)
            minute_metrics = Metrics(enabled=False)

            print('2. Ovewrite Queue service properties')
            queue_service.set_queue_service_properties(
                logging=logging,
                hour_metrics=hour_metrics,
                minute_metrics=minute_metrics)
        finally:
            print(
                '3. Revert Queue service properties back to the original ones')
            queue_service.set_queue_service_properties(
                logging=props.logging,
                hour_metrics=props.hour_metrics,
                minute_metrics=props.minute_metrics)

        print('4. Set Queue service properties completed')
    def test_retention_too_long(self):
        # Arrange
        minute_metrics = Metrics(enabled=True, include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True, days=366))

        # Assert
        self.assertRaises(AzureHttpError,
                          self.bs.set_blob_service_properties,
                          None, None, minute_metrics)
    def test_set_hour_metrics(self):
        # Arrange
        hour_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        self.bs.set_blob_service_properties(hour_metrics=hour_metrics)

        # Assert
        received_props = self.bs.get_blob_service_properties()
        self._assert_metrics_equal(received_props.hour_metrics, hour_metrics)
    def test_set_logging(self):
        # Arrange
        logging = Logging(read=True, write=True, delete=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        self.bs.set_blob_service_properties(logging=logging)

        # Assert
        received_props = self.bs.get_blob_service_properties()
        self._assert_logging_equal(received_props.logging, logging)
    def set_service_properties(self, file_service):

        print('1. Get File service properties')
        props = file_service.get_file_service_properties()

        retention = RetentionPolicy(enabled=True, days=5)
        hour_metrics = Metrics(enabled=True,
                               include_apis=True,
                               retention_policy=retention)
        minute_metrics = Metrics(enabled=False)

        try:
            print('2. Ovewrite File service properties')
            file_service.set_file_service_properties(
                hour_metrics=hour_metrics, minute_metrics=minute_metrics)

        finally:
            print(
                '3. Revert File service properties back to the original ones')
            file_service.set_file_service_properties(
                hour_metrics=props.hour_metrics,
                minute_metrics=props.minute_metrics)

        print('4. Set File service properties completed')