def json_to_trend(self, response): if isinstance(response, list): trends = [] for tr in response: trend = self.json_to_trend(tr) trends.append(trend) return trends else: trend = Trend() trend.name = response['name'] trend.promoted = False if response['promoted_content']: trend.promoted = True return trend
def json_to_trend(self, response): if isinstance(response, list): trends = [] for tr in response: trend = self.json_to_trend(tr) trends.append(trend) return trends else: trend = Trend(response['name']) trend.query = response['query'] trend.url = response['url'] if response['promoted_content']: trend.is_promoted = True return trend
def json_to_trend(self, response): if isinstance(response, list): trends = [] for tr in response: trend = self.json_to_trend(tr) trends.append(trend) return trends else: trend = Trend(response["name"]) trend.query = response["query"] trend.url = response["url"] if response["promoted_content"]: trend.is_promoted = True return trend
def test_get_trending_topics(self, monkeypatch): trend = Trend('Foo') monkeypatch.setattr(self.account, "trends", lambda x: [trend]) response = self.core.get_trending_topics(self.acc_id, "here") assert isinstance(response, list) assert response[0] == trend