def test_render_empty_no_query(self): # When we haven't fetched, we shouldn't show any columns (for # consistency with other modules) result = twitter.render(pd.DataFrame(), P(querytype='search', query=''), fetch_result=None) assert_frame_equal(result, pd.DataFrame())
def test_render_truncate_fetch_results(self): # This is an edge case for [2019-05-28] and thereabouts: if we somehow # re-render a fetch that had more than 100k rows, truncate it to save # RAM on subsequent modules. result = twitter.render(pd.DataFrame(), P(querytype='search', query='cat'), fetch_result=ProcessResult(mock_tweet_table)) assert_frame_equal(result['dataframe'], mock_tweet_table.iloc[[0]])
def test_render_empty_search_result(self): # An empty table might be stored as zero-column. This is a bug, but we # must handle it because we have actual data like this. We want to # output all the same columns as a tweet table. result = twitter.render(pd.DataFrame(), P(querytype='search', query='cat'), fetch_result=ProcessResult(pd.DataFrame())) assert_frame_equal(result.dataframe, mock_tweet_table[0:0])
def test_render_empty_search_result(self): # An empty table might be stored as zero-column. This is a bug, but we # must handle it because we have actual data like this. We want to # output all the same columns as a tweet table. result = twitter.render(pd.DataFrame(), P(querytype='search', query='cat'), fetch_result=ProcessResult(pd.DataFrame())) assert_frame_equal(result['dataframe'], mock_tweet_table[0:0]) # column_formats is needed even for empty tables, so we can concat them self.assertEqual(result['column_formats'], {'id': '{:d}'})