1+ import cgi
12import json
23import os
34import pytest
45import requests
6+ from io import BytesIO
57
68from docarray import DocumentArray
79from docarray .array .mixins .io .pushpull import JINA_CLOUD_CONFIG
@@ -82,6 +84,27 @@ def test_push(mocker, monkeypatch):
8284 assert mock .call_count == 1
8385
8486
87+ @pytest .mark .parametrize ('public' , [True , False ])
88+ def test_push_with_public (mocker , monkeypatch , public ):
89+ mock = mocker .Mock ()
90+ _mock_post (mock , monkeypatch )
91+
92+ docs = random_docs (2 )
93+ docs .push (name = 'test_name' , public = public )
94+
95+ _ , mock_kwargs = mock .call_args_list [0 ]
96+
97+ c_type , c_data = cgi .parse_header (mock_kwargs ['headers' ]['Content-Type' ])
98+ assert c_type == 'multipart/form-data'
99+
100+ form_data = cgi .parse_multipart (
101+ BytesIO (b'' .join (mock_kwargs ['data' ])),
102+ {'boundary' : c_data ['boundary' ].encode ()},
103+ )
104+
105+ assert form_data ['public' ] == [str (public )]
106+
107+
85108def test_pull (mocker , monkeypatch ):
86109 mock = mocker .Mock ()
87110 _mock_get (mock , monkeypatch )
@@ -104,7 +127,7 @@ def test_push_fail(mocker, monkeypatch):
104127 _mock_post (mock , monkeypatch , status_code = requests .codes .forbidden )
105128
106129 docs = random_docs (2 )
107- with pytest .raises (Exception ) as exc_info :
130+ with pytest .raises (Exception ):
108131 docs .push ('test_name' )
109132
110133 assert mock .call_count == 1
0 commit comments