Example #1
0
    def test_get_blogs(self):
        api = PhishNetAPI()
        blogs_response = api.get_blogs(year=2009)

        assert blogs_response['error_code'] == 0
        assert blogs_response['response']['count'] == len(
            blogs_response['response']['data'])

        with pytest.raises(ParamValidationError):
            api.get_blogs(year=2008)
            api.get_blogs(year=2020)
Example #2
0
    def test_get_blogs(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/recent_blogs.json') as f:
            get_blogs_json = json.load(f)
        requests_mock.post(api.base_url + "blog/get", json=get_blogs_json)

        blogs_response = api.get_blogs(year=2009)
        assert blogs_response['response']['count'] == 3
        assert len(blogs_response['response']['data']) == 3

        with pytest.raises(ParamValidationError):
            api.get_blogs(year=2008)
            api.get_blogs(year=2020)