def _assert_properties_default(self, prop):
        assert prop is not None

        self._assert_logging_equal(prop["analytics_logging"],
                                   TableAnalyticsLogging())
        self._assert_metrics_equal(prop["hour_metrics"], TableMetrics())
        self._assert_metrics_equal(prop["minute_metrics"], TableMetrics())
        self._assert_cors_equal(prop["cors"], list())
Esempio n. 2
0
    def test_create_properties(self, tables_storage_account_name, tables_primary_storage_account_key):
        # # Arrange
        account_url = self.account_url(tables_storage_account_name, "table")
        ts = TableServiceClient(credential=tables_primary_storage_account_key, endpoint=account_url)
        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()
        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=TableMetrics(
                enabled=True,
                include_apis=True,
                retention_policy=TableRetentionPolicy(enabled=True, days=5)
            )
        )

        ps = ts.get_service_properties()
        ts.delete_table(table_name)
Esempio n. 3
0
    async def test_aad_service_properties(self, tables_storage_account_name):
        try:
            account_url = self.account_url(tables_storage_account_name,
                                           "table")
            ts = TableServiceClient(credential=self.get_token_credential(),
                                    endpoint=account_url)
            table_name = self._get_table_reference()
            created = await ts.create_table(table_name)

            assert created.table_name == table_name

            properties = await ts.get_service_properties()
            await ts.set_service_properties(
                analytics_logging=TableAnalyticsLogging(write=True))
            # have to wait async for return to service
            p = await ts.get_service_properties()
            # have to wait async for return to service
            await ts.set_service_properties(minute_metrics=TableMetrics(
                enabled=True,
                include_apis=True,
                retention_policy=TableRetentionPolicy(enabled=True, days=5)))

            ps = await ts.get_service_properties()
        finally:
            await ts.delete_table(table_name)
Esempio n. 4
0
    def test_table_service_properties(self, tables_storage_account_name,
                                      tables_primary_storage_account_key):
        # Arrange
        url = self.account_url(tables_storage_account_name, "table")
        tsc = TableServiceClient(url,
                                 credential=tables_primary_storage_account_key)
        # Act
        resp = tsc.set_service_properties(
            analytics_logging=TableAnalyticsLogging(),
            hour_metrics=TableMetrics(),
            minute_metrics=TableMetrics(),
            cors=list())

        # Assert
        assert resp is None
        if self.is_live:
            time.sleep(45)
        self._assert_properties_default(tsc.get_service_properties())
    def test_retention_too_long(self, tables_cosmos_account_name,
                                tables_primary_cosmos_account_key):
        tsc = TableServiceClient(self.account_url(tables_cosmos_account_name,
                                                  "cosmos"),
                                 credential=tables_primary_cosmos_account_key)
        minute_metrics = TableMetrics(enabled=True,
                                      include_apis=True,
                                      retention_policy=TableRetentionPolicy(
                                          enabled=True, days=366))

        with pytest.raises(HttpResponseError):
            tsc.set_service_properties(minute_metrics=minute_metrics)
Esempio n. 6
0
    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"),
                                 credential=tables_primary_storage_account_key)
        minute_metrics = TableMetrics(enabled=True,
                                      include_apis=True,
                                      retention_policy=TableRetentionPolicy(
                                          enabled=True, days=366))

        # Assert
        pytest.raises(HttpResponseError,
                      tsc.set_service_properties,
                      minute_metrics=minute_metrics)
Esempio 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, "table")
        tsc = TableServiceClient(url,
                                 credential=tables_primary_storage_account_key)
        minute_metrics = TableMetrics(enabled=True,
                                      include_apis=True,
                                      retention_policy=TableRetentionPolicy(
                                          enabled=True, days=5))

        # Act
        tsc.set_service_properties(minute_metrics=minute_metrics)

        # Assert
        if self.is_live:
            time.sleep(45)
        received_props = tsc.get_service_properties()
        self._assert_metrics_equal(received_props['minute_metrics'],
                                   minute_metrics)