def test_create_data_feed_with_postgresql(self):
        name = self.create_random_name("postgresql")
        try:
            data_feed = self.admin_client.create_data_feed(
                name=name,
                source=PostgreSqlDataFeedSource(
                    connection_string=self.postgresql_connection_string,
                    query=
                    "'select * from adsample2 where Timestamp = @StartTime'"),
                granularity=DataFeedGranularity(granularity_type="Daily", ),
                schema=DataFeedSchema(
                    metrics=[
                        DataFeedMetric(name="cost"),
                        DataFeedMetric(name="revenue")
                    ],
                    dimensions=[
                        DataFeedDimension(name="category"),
                        DataFeedDimension(name="city")
                    ],
                ),
                ingestion_settings=DataFeedIngestionSettings(
                    ingestion_begin_time=datetime.datetime(2019, 1, 1), ),
            )

            self.assertIsNotNone(data_feed.id)
            self.assertIsNotNone(data_feed.created_time)
            self.assertIsNotNone(data_feed.name)
            self.assertEqual(data_feed.source.data_source_type, "PostgreSql")
            self.assertEqual(
                data_feed.source.query,
                "'select * from adsample2 where Timestamp = @StartTime'")

        finally:
            self.admin_client.delete_data_feed(data_feed.id)
    def test_create_data_feed_with_postgresql(self, client, variables):
        name = self.create_random_name("postgresql")
        if self.is_live:
            variables["data_feed_name"] = name
        try:
            data_feed = client.create_data_feed(
                name=variables["data_feed_name"],
                source=PostgreSqlDataFeedSource(
                    connection_string="postgresql_connection_string",
                    query=
                    "'select * from adsample2 where Timestamp = @StartTime'"),
                granularity=DataFeedGranularity(granularity_type="Daily", ),
                schema=DataFeedSchema(
                    metrics=[
                        DataFeedMetric(name="cost"),
                        DataFeedMetric(name="revenue")
                    ],
                    dimensions=[
                        DataFeedDimension(name="category"),
                        DataFeedDimension(name="city")
                    ],
                ),
                ingestion_settings=DataFeedIngestionSettings(
                    ingestion_begin_time=datetime.datetime(2019, 1, 1), ),
            )
            if self.is_live:
                variables["data_feed_id"] = data_feed.id
            assert data_feed.id is not None
            assert data_feed.created_time is not None
            assert data_feed.name is not None
            assert data_feed.source.data_source_type == "PostgreSql"
            assert data_feed.source.query == "'select * from adsample2 where Timestamp = @StartTime'"

        finally:
            self.clean_up(client.delete_data_feed, variables)
        return variables