def test_event_list_request_can_set_page_limit(self): with mock_response(): cased.policy_key = "cs_test_001" Event.list(limit=10) cased.http.HTTPClient.make_request.assert_called_with( "get", "https://api.cased.com/events/", "cs_test_001", {"per_page": 10} )
def test_event_list_request_is_called_with_correct_url(self): with mock_response(): cased.policy_key = "cs_test_001" Event.list() cased.http.HTTPClient.make_request.assert_called_with( "get", "https://api.cased.com/events/", "cs_test_001", {"per_page": 25} )
def test_events_can_be_listed_and_filtered_with_variables(self): with mock_response(): cased.policy_key = "cs_test_001" Event.list(variables={"team": "team_1"}) cased.http.HTTPClient.make_request.assert_called_with( "get", "https://api.cased.com/events/", "cs_test_001", {"per_page": 25, "variables[team]": "team_1"}, )
def test_events_can_be_filtered_with_multiple_variables(self): with mock_response(): cased.policy_key = "cs_test_001" Event.list(limit=10, variables={"team": "team_1", "organization": "org_1"}) cased.http.HTTPClient.make_request.assert_called_with( "get", "https://api.cased.com/events/", "cs_test_001", { "per_page": 10, "variables[team]": "team_1", "variables[organization]": "org_1", }, )
def test_event_list_request_has_correct_paramaters_with_a_long_phrase(self): with mock_response(): cased.policy_key = "cs_test_001" Event.list( search=Query.make_phrase_from_dict( {"actor": "test", "event": "user.login"} ) ) cased.http.HTTPClient.make_request.assert_called_with( "get", "https://api.cased.com/events/", "cs_test_001", {"per_page": 25, "phrase": "(actor:test AND event:user.login)"}, )
def test_events_are_listable(self): with mock_response(): cased.policy_key = "cs_test_001" assert Event.list().json_response
def test_events_filter_variables_requires_a_dict(self): with mock_response(): cased.policy_key = "cs_test_001" with pytest.raises(TypeError): Event.list(limit=10, variables=["data", "more-data"])