Esempio n. 1
0
    def test_desc(self, mock_client):
        mock_client.investigations.search(sort('created_at', '-'))
        result = get_url_from_request_mock(mock_client)
        assert result == '/api/v2/investigations?sort=-created_at'

        mock_client.investigations.search(sort('created_at', 'desc'))
        result = get_url_from_request_mock(mock_client)
        assert result == '/api/v2/investigations?sort=-created_at'
Esempio n. 2
0
    def test_default(self, mock_client):
        mock_client.investigations.search()
        result = get_url_from_request_mock(mock_client)
        assert result == '/api/v2/investigations?sort=+created_at&sort=+id'

        mock_client.investigations.search(sort('created_at'))
        result = get_url_from_request_mock(mock_client)
        assert result == '/api/v2/investigations?sort=+created_at'
Esempio n. 3
0
 def test_search_more_complex_args(self, mock_client):
     args = [
         relationship('investigation.created_at',
                      gt(datetime.datetime(2020, 1, 1))),
         relationship('investigation.created_at',
                      lt(datetime.datetime(2020, 5, 1))),
         relationship('investigation.organization.id', ORGANIZATION_ID),
         sort('created_at')
     ]
     kwargs = {
         'action_types': 'MANUAL',
         'some_count': gt(25),
         'some_other_count': window(1, 5)
     }
     mock_client.investigative_actions.search(*args, **kwargs)
     result = get_url_from_request_mock(mock_client)
     assert result == '/api/v2/investigative_actions?filter[investigation][created_at]=>2020-01-01T00:00:00&filter[investigation][created_at]=<2020-05-01T00:00:00&filter[investigation][organization][id]=11111111-1111-1111-1111-111111111111&sort=+created_at&filter[action_types]=MANUAL&filter[some_count]=>25&filter[some_other_count]=>1&filter[some_other_count]=<5'
Esempio n. 4
0
 def test_search_sort(self, mock_client):
     mock_client.investigative_actions.search(sort('some_timestamp', '-'))
     result = get_url_from_request_mock(mock_client)
     assert result == '/api/v2/investigative_actions?sort=-some_timestamp'
Esempio n. 5
0
 def test_value_error(self, mock_client):
     with pytest.raises(ValueError):
         sort('field', 12341434)
Esempio n. 6
0
 def test_multiple(self, mock_client):
     mock_client.investigations.search(sort('created_at', '-'),
                                       sort('id', '+'),
                                       sort('closed_at', '-'))
     result = get_url_from_request_mock(mock_client)
     assert result == '/api/v2/investigations?sort=-created_at&sort=+id&sort=-closed_at'