Ejemplo n.º 1
0
def test_help():
    """The -h flag should raise SysExit with base.py's docstring."""

    # shouldn't matter the order the -h comes in
    sys.argv.extend(["-u", "someone", "-s", "-h", "wow", "much", "search"])
    with pytest.raises(SystemExit) as raises:
        parse_args()

    assert base.__doc__.strip() in raises.value.args
Ejemplo n.º 2
0
def test_help():
    """The -h flag should raise SysExit with base.py's docstring."""

    # shouldn't matter the order the -h comes in
    sys.argv.extend(["-u", "someone", "-s", "-h", "wow", "much", "search"])
    with pytest.raises(SystemExit) as raises:
        parse_args()

    assert base.__doc__.strip() in raises.value.args
Ejemplo n.º 3
0
def test_max_with_negative_search():
    """Should be able to use -int with NOT search phrases."""

    sys.argv.extend(["-6", "-apples", "pears"])
    settings = parse_args()
    assert settings.get("max") == 6
    assert settings.get("search") == ["-apples", "pears"]
Ejemplo n.º 4
0
def test_max_with_negative_search():
    """Should be able to use -int with NOT search phrases."""

    sys.argv.extend(["-6", "-apples", "pears"])
    settings = parse_args()
    assert settings.get("max") == 6
    assert settings.get("search") == ["-apples", "pears"]
Ejemplo n.º 5
0
def test_time_and_date_flags():
    """Test using the time and the date flags."""

    sys.argv.extend(["-t", "-d"])
    settings = parse_args()
    assert settings.get("date")
    assert settings.get("time")
Ejemplo n.º 6
0
def test_time_and_date_flags():
    """Test using the time and the date flags."""

    sys.argv.extend(["-t", "-d"])
    settings = parse_args()
    assert settings.get("date")
    assert settings.get("time")
Ejemplo n.º 7
0
def test_search_phrase_with_hyphen():
    """Allow `-non-int` as a search phrase."""

    # NB: doing this will return a 403 from Twitter, you need at least one
    #     positive search phrase.
    sys.argv.append("-7e4")
    settings = parse_args()
    assert settings.get("max") == 3
    assert settings.get("search") == ["-7e4"]
Ejemplo n.º 8
0
def test_time_date_and_stream_flags():
    """Test using the time, date and stream flags."""

    sys.argv.extend(["-t", "-d", "-s", "some", "phrase"])
    settings = parse_args()
    assert settings.get("date")
    assert settings.get("time")
    assert settings.get("stream")
    assert settings.get("search", ["some", "phrase"])
Ejemplo n.º 9
0
def test_time_date_and_stream_flags():
    """Test using the time, date and stream flags."""

    sys.argv.extend(["-t", "-d", "-s", "some", "phrase"])
    settings = parse_args()
    assert settings.get("date")
    assert settings.get("time")
    assert settings.get("stream")
    assert settings.get("search", ["some", "phrase"])
Ejemplo n.º 10
0
def test_search_phrase_with_hyphen():
    """Allow `-non-int` as a search phrase."""

    # NB: doing this will return a 403 from Twitter, you need at least one
    #     positive search phrase.
    sys.argv.append("-7e4")
    settings = parse_args()
    assert settings.get("max") == 3
    assert settings.get("search") == ["-7e4"]
Ejemplo n.º 11
0
def test_multiple_phrases():
    """Tests using more than one search keyword."""

    sys.argv.extend(["rainbows", "unicorns"])
    settings = parse_args()
    assert settings.get("search") == ["rainbows", "unicorns"]
Ejemplo n.º 12
0
def test_search_tweets():
    """Tests search phrases."""

    sys.argv.append("ponies")
    settings = parse_args()
    assert settings.get("search") == ["ponies"]
Ejemplo n.º 13
0
def test_user_tweets():
    """Test specifiying tweets from a particular user."""

    sys.argv.extend(["-u", "billy"])
    settings = parse_args()
    assert settings.get("user") == "billy"
Ejemplo n.º 14
0
def test_max_tweets():
    """Tests the -integer max tweet option."""

    sys.argv.append("-14")
    settings = parse_args()
    assert settings.get("max") == 14
Ejemplo n.º 15
0
def test_date_flag():
    """Test using the date flag."""

    sys.argv.append("-d")
    settings = parse_args()
    assert settings.get("date")
Ejemplo n.º 16
0
def test_json_flag():
    """Test using the -j flag to dump the tweet jsons."""

    sys.argv.append("-j")
    settings = parse_args()
    assert settings.get("json")
Ejemplo n.º 17
0
def test_spam_flag():
    """Test using the disable anti-spam flag."""

    sys.argv.append("-n")
    settings = parse_args()
    assert settings.get("spam")
Ejemplo n.º 18
0
def test_json_flag():
    """Test using the -j flag to dump the tweet jsons."""

    sys.argv.append("-j")
    settings = parse_args()
    assert settings.get("json")
Ejemplo n.º 19
0
def test_search_tweets():
    """Tests search phrases."""

    sys.argv.append("ponies")
    settings = parse_args()
    assert settings.get("search") == ["ponies"]
Ejemplo n.º 20
0
def test_spam_flag():
    """Test using the disable anti-spam flag."""

    sys.argv.append("-n")
    settings = parse_args()
    assert settings.get("spam")
Ejemplo n.º 21
0
def test_time_flag():
    """Test using the time flag."""

    sys.argv.append("-t")
    settings = parse_args()
    assert settings.get("time")
Ejemplo n.º 22
0
def test_date_flag():
    """Test using the date flag."""

    sys.argv.append("-d")
    settings = parse_args()
    assert settings.get("date")
Ejemplo n.º 23
0
def test_stream():
    """Test that setting only the stream flag raises an error."""

    sys.argv.append("-s")
    with pytest.raises(SystemExit):
        parse_args()
Ejemplo n.º 24
0
def test_user_tweets():
    """Test specifiying tweets from a particular user."""

    sys.argv.extend(["-u", "billy"])
    settings = parse_args()
    assert settings.get("user") == "billy"
Ejemplo n.º 25
0
def test_negative_search():
    """We should be able to use a - at the start of a phrase to NOT it."""

    sys.argv.extend(["-something", "theotherthing"])
    settings = parse_args()
    assert settings.get("search") == ["-something", "theotherthing"]
Ejemplo n.º 26
0
def test_stream():
    """Test that setting only the stream flag raises an error."""

    sys.argv.append("-s")
    with pytest.raises(SystemExit):
        parse_args()
Ejemplo n.º 27
0
def test_max_tweets():
    """Tests the -integer max tweet option."""

    sys.argv.append("-14")
    settings = parse_args()
    assert settings.get("max") == 14
Ejemplo n.º 28
0
def test_time_flag():
    """Test using the time flag."""

    sys.argv.append("-t")
    settings = parse_args()
    assert settings.get("time")
Ejemplo n.º 29
0
def test_negative_search():
    """We should be able to use a - at the start of a phrase to NOT it."""

    sys.argv.extend(["-something", "theotherthing"])
    settings = parse_args()
    assert settings.get("search") == ["-something", "theotherthing"]
Ejemplo n.º 30
0
def settings():
    _settings = parse_args()
    _settings.update({"spam": True})
    return _settings
Ejemplo n.º 31
0
def test_multiple_phrases():
    """Tests using more than one search keyword."""

    sys.argv.extend(["rainbows", "unicorns"])
    settings = parse_args()
    assert settings.get("search") == ["rainbows", "unicorns"]