Exemplo n.º 1
0
    def test_query_shows(self):
        api = PhishNetAPI()
        query_shows_response = api.query_shows(tourid=37)

        assert query_shows_response['error_code'] == 0
        assert query_shows_response['response']['count'] == 21
        assert len(query_shows_response['response']['data']) == 21
        assert query_shows_response['response']['data'][0][
            'showid'] == 1252697421

        with pytest.raises(ParamValidationError):
            api.query_shows(year=1982)
        with pytest.raises(ParamValidationError):
            api.query_shows(month=13)
        with pytest.raises(ParamValidationError):
            api.query_shows(day=32)
        with pytest.raises(ParamValidationError):
            api.query_shows(showdate_gt=1982)
Exemplo n.º 2
0
    def test_query_shows(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/query_shows.json') as f:
            query_shows_json = json.load(f)
        requests_mock.post(api.base_url + "shows/query", json=query_shows_json)

        query_shows_response = api.query_shows(tourid=37)
        assert query_shows_response['response']['count'] == 14
        assert len(query_shows_response['response']['data']) == 14
        assert query_shows_response['response']['data'][0][
            'showid'] == 1252691618

        with pytest.raises(ParamValidationError):
            api.query_shows(year=1982)
        with pytest.raises(ParamValidationError):
            api.query_shows(month=13)
        with pytest.raises(ParamValidationError):
            api.query_shows(day=32)
        with pytest.raises(ParamValidationError):
            api.query_shows(showdate_gt=1982)