def test_stream_delete_from_id(): s = Stream(query=VALID_WHERE_STATEMENT) s.create() time.sleep(60) response = s.delete() assert isinstance(response, StreamResponse) assert len(response.id) > 0
def test_create_stream_with_query(): s = Stream(query=VALID_WHERE_STATEMENT) assert s.query.get_base_query() == { 'query': { 'where': VALID_WHERE_STATEMENT } }
def test_stream_get_info_from_id(): s = Stream(stream_id=VALID_STREAM_ID) response = s.get_info() assert isinstance(response, StreamResponse) assert len(response.id) > 0
def test_stream_create_from_query(): s = Stream(query=VALID_WHERE_STATEMENT) response = s.create() assert isinstance(response, StreamResponse) assert len(response.id) > 0
def test_create_stream_invalid_stream(): with pytest.raises(ValueError, match=r'Not allowed stream id with query or snapshot'): Stream(api_key_user=VALID_USER_KEY, query=VALID_WHERE_STATEMENT, stream_id=VALID_STREAM_ID)
def test_create_stream_existing_user(): stream = Stream(stream_user=stream_user) assert stream.stream_user.api_key == VALID_USER_KEY
def test_create_stream_request_info(): stream = Stream(api_key_user=VALID_USER_KEY, request_userinfo=True) assert len(stream.stream_user.account_name) > 0 assert stream.stream_user.max_allowed_extracted_documents != 0
def test_create_stream_str_key(): stream = Stream(api_key_user=VALID_USER_KEY) assert stream.stream_user.api_key == VALID_USER_KEY
def test_create_stream_evironment_variable(): stream = Stream() assert stream.stream_user.api_key == ENVIRONMENT_USER_KEY