예제 #1
0
def test_add_delete_filter(delete_filter_keys):
    """Tests an API call to add and delete a filter"""

    response_add = Filter(monitor_id=17906955697,
                          title="Test Title",
                          keywords="Twitter")

    assert isinstance(response_add, Filter)
    assert isinstance(response_add.id, int)

    response_delete = response_add.delete()

    assert isinstance(response_delete, dict)
    assert set(delete_filter_keys).issubset(
        response_delete.keys()), "All keys should be in the response"
예제 #2
0
def test_filter_get_posts_data(posts_data_keys):
    """Tests an API call to get posts for specific filter"""

    response = Filter(17109666567).get_posts_data(start="2016-01-01",
                                                  end="2016-01-03")

    assert isinstance(response, list)
    assert isinstance(response[0], dict)
    assert set(posts_data_keys).issubset(
        response[0].keys()), "All keys should be in the response"
예제 #3
0
def get_filter_data(monitor_id, keywords, title, query_dir, progress):
    print progress + " filters: Adding filter for " + title + "..."
    # make filter
    new_filter = Filter(monitor_id=monitor_id, title=title, keywords=keywords)
    # save volume_data to csv
    print "Getting volume data for " + title + "..."
    new_filter.volume_to_csv(start=start,
                             end=end,
                             output_filename=query_dir + "volume_data.csv")
    # save sentiment_data to csv
    print "Getting sentiment data for " + title + "..."
    new_filter.sentiment_to_csv(start=start,
                                end=end,
                                output_filename=query_dir +
                                "sentiment_data.csv")
예제 #4
0
def add_filter(monitor_id, keywords, title, progress):
    print progress + " filters: Adding filter for " + title + "..."
    # make filter
    new_filter = Filter(monitor_id=monitor_id, title=title, keywords=keywords)
    return new_filter