def test_create_properties(self, resource_group, location, storage_account,
                               storage_account_key):
        # # Arrange
        ts = TableServiceClient(self.account_url(storage_account, "table"),
                                storage_account_key)
        table_name = self._get_table_reference()
        # Act
        created = ts.create_table(table_name)

        # Assert
        assert created.table_name == table_name

        properties = ts.get_service_properties()
        print(properties)
        ts.set_service_properties(analytics_logging=TableAnalyticsLogging(
            write=True))
        # have to wait for return to service
        p = ts.get_service_properties()
        # have to wait for return to service
        ts.set_service_properties(minute_metrics=Metrics(
            enabled=True,
            include_apis=True,
            retention_policy=RetentionPolicy(enabled=True, days=5)))

        ps = ts.get_service_properties()
        print(ps)
        print(p)
        ts.delete_table(table_name)
Exemplo n.º 2
0
    async def test_retention_too_long_async(self, resource_group, location, storage_account, storage_account_key):
        # Arrange
        tsc = TableServiceClient(self.account_url(storage_account, "table"), storage_account_key)
        minute_metrics = Metrics(enabled=True, include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True, days=366))

        # Assert
        with self.assertRaises(HttpResponseError):
            await tsc.set_service_properties(None, None, minute_metrics)
    async def test_retention_too_long_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key):
        # Arrange
        tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key)
        minute_metrics = Metrics(enabled=True, include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True, days=366))

        # Assert
        with pytest.raises(HttpResponseError):
            await tsc.set_service_properties(None, None, minute_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
    async def test_retention_too_long_async(self, resource_group, location, cosmos_account, cosmos_account_key):
        # Arrange
        tsc = TableServiceClient(self.account_url(cosmos_account, "cosmos"), cosmos_account_key)
        minute_metrics = Metrics(enabled=True, include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True, days=366))

        await tsc.set_service_properties(None, None, minute_metrics)
        # Assert
        pytest.raises(HttpResponseError,
                          tsc.set_service_properties,
                          None, None, minute_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
    async def test_set_hour_metrics_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key):
        # Arrange
        url = self.account_url(tables_cosmos_account_name, "cosmos")
        tsc = TableServiceClient(url, tables_primary_cosmos_account_key)
        hour_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        await tsc.set_service_properties(hour_metrics=hour_metrics)

        # Assert
        received_props = await tsc.get_service_properties()
        self._assert_metrics_equal(received_props['hour_metrics'], hour_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
    def test_retention_too_long(self, tables_storage_account_name,
                                tables_primary_storage_account_key):
        # Arrange
        tsc = TableServiceClient(
            self.account_url(tables_storage_account_name, "table"),
            tables_primary_storage_account_key)
        minute_metrics = Metrics(enabled=True,
                                 include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True,
                                                                  days=366))

        # Assert
        pytest.raises(HttpResponseError, tsc.set_service_properties, None,
                      None, minute_metrics)
Exemplo n.º 7
0
    def test_set_minute_metrics(self, tables_storage_account_name, tables_primary_storage_account_key):
        # Arrange
        url = self.account_url(tables_storage_account_name, "cosmos")
        tsc = TableServiceClient(url, tables_primary_storage_account_key)
        minute_metrics = Metrics(enabled=True, include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        tsc.set_service_properties(minute_metrics=minute_metrics)

        # Assert
        received_props = tsc.get_service_properties()
        self._assert_metrics_equal(received_props['minute_metrics'], minute_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
    async def test_set_minute_metrics_async(self, resource_group, location, cosmos_account, cosmos_account_key):
        # Arrange
        url = self.account_url(cosmos_account, "cosmos")
        tsc = TableServiceClient(url, cosmos_account_key)
        minute_metrics = Metrics(enabled=True, include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        await tsc.set_service_properties(minute_metrics=minute_metrics)

        # Assert
        received_props = await tsc.get_service_properties()
        self._assert_metrics_equal(received_props['minute_metrics'], minute_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
Exemplo n.º 9
0
    def test_set_hour_metrics(self, resource_group, location, storage_account, storage_account_key):
        # Arrange
        url = self.account_url(storage_account, "table")
        if 'cosmos' in url:
            pytest.skip("Cosmos Tables does not yet support service properties")
        tsc = TableServiceClient(url, storage_account_key)
        hour_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        tsc.set_service_properties(hour_metrics=hour_metrics)

        # Assert
        if self.is_live:
            time.sleep(30)
        received_props = tsc.get_service_properties()
        self._assert_metrics_equal(received_props['hour_metrics'], hour_metrics)
    async def test_set_hour_metrics_async(self, resource_group, location, cosmos_account, cosmos_account_key):
        # Arrange
        url = self.account_url(cosmos_account, "cosmos")
        if 'cosmos' in url:
            pytest.skip("Cosmos Tables does not yet support service properties")
        tsc = TableServiceClient(url, cosmos_account_key)
        hour_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        await tsc.set_service_properties(hour_metrics=hour_metrics)

        # Assert
        received_props = await tsc.get_service_properties()
        self._assert_metrics_equal(received_props['hour_metrics'], hour_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
    def test_set_hour_metrics(self, tables_storage_account_name,
                              tables_primary_storage_account_key):
        # Arrange
        url = self.account_url(tables_storage_account_name, "table")
        tsc = TableServiceClient(url, tables_primary_storage_account_key)
        hour_metrics = Metrics(enabled=True,
                               include_apis=True,
                               retention_policy=RetentionPolicy(enabled=True,
                                                                days=5))

        # Act
        tsc.set_service_properties(hour_metrics=hour_metrics)

        # Assert
        if self.is_live:
            time.sleep(30)
        received_props = tsc.get_service_properties()
        self._assert_metrics_equal(received_props['hour_metrics'],
                                   hour_metrics)
    def test_set_hour_metrics(self, resource_group, location, storage_account,
                              storage_account_key):
        # Arrange
        url = self.account_url(storage_account, "cosmos")
        tsc = TableServiceClient(url, storage_account_key)
        hour_metrics = Metrics(enabled=True,
                               include_apis=True,
                               retention_policy=RetentionPolicy(enabled=True,
                                                                days=5))

        # Act
        tsc.set_service_properties(hour_metrics=hour_metrics)

        # Assert
        received_props = tsc.get_service_properties()
        self._assert_metrics_equal(received_props['hour_metrics'],
                                   hour_metrics)
        if self.is_live:
            sleep(SLEEP_DELAY)
    def test_set_minute_metrics(self, resource_group, location,
                                storage_account, storage_account_key):
        # Arrange
        url = self.account_url(storage_account, "table")
        tsc = TableServiceClient(url, storage_account_key)
        minute_metrics = Metrics(enabled=True,
                                 include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True,
                                                                  days=5))

        # Act
        tsc.set_service_properties(minute_metrics=minute_metrics)

        # Assert
        if self.is_live:
            time.sleep(30)
        received_props = tsc.get_service_properties()
        self._assert_metrics_equal(received_props['minute_metrics'],
                                   minute_metrics)
Exemplo n.º 14
0
    async def test_set_logging_async(self, tables_storage_account_name,
                                     tables_primary_storage_account_key):
        # Arrange
        url = self.account_url(tables_storage_account_name, "table")
        tsc = TableServiceClient(url, tables_primary_storage_account_key)
        logging = TableAnalyticsLogging(read=True,
                                        write=True,
                                        delete=True,
                                        retention_policy=RetentionPolicy(
                                            enabled=True, days=5))

        # Act
        await tsc.set_service_properties(analytics_logging=logging)

        # Assert
        if self.is_live:
            time.sleep(30)
        received_props = await tsc.get_service_properties()
        self._assert_logging_equal(received_props['analytics_logging'],
                                   logging)
    def test_set_logging(self, resource_group, location, storage_account,
                         storage_account_key):
        # Arrange
        url = self.account_url(storage_account, "cosmos")
        tsc = TableServiceClient(url, storage_account_key)
        logging = TableAnalyticsLogging(read=True,
                                        write=True,
                                        delete=True,
                                        retention_policy=RetentionPolicy(
                                            enabled=True, days=5))

        # Act
        tsc.set_service_properties(analytics_logging=logging)

        # Assert
        received_props = tsc.get_service_properties()
        self._assert_logging_equal(received_props['analytics_logging'],
                                   logging)
        if self.is_live:
            time.sleep(30)
Exemplo n.º 16
0
    async def test_set_logging_async(self, resource_group, location,
                                     storage_account, storage_account_key):
        # Arrange
        url = self.account_url(storage_account, "table")
        if 'cosmos' in url:
            pytest.skip(
                "Cosmos Tables does not yet support service properties")
        tsc = TableServiceClient(url, storage_account_key)
        logging = TableAnalyticsLogging(read=True,
                                        write=True,
                                        delete=True,
                                        retention_policy=RetentionPolicy(
                                            enabled=True, days=5))

        # Act
        await tsc.set_service_properties(analytics_logging=logging)

        # Assert
        if self.is_live:
            time.sleep(30)
        received_props = await tsc.get_service_properties()
        self._assert_logging_equal(received_props['analytics_logging'],
                                   logging)