@@ -847,9 +847,10 @@ def test_sync_stream(
847847
848848 with open ('./tests/fixtures/commerce/stream_retrieve_response.json' ) as content :
849849 response = json .load (content )[0 ]
850+ response ['status' ] = 'configuring'
850851 mocked_responses .add (
851852 method = 'GET' ,
852- url = 'https://localhost/public/v1/billing/streams?eq(id,STR-7748-7021-7449)&select(context,samples,sources)&limit=1&offset=0' ,
853+ url = 'https://localhost/public/v1/billing/streams?eq(id,STR-7748-7021-7449)&select(context,samples,sources,validation )&limit=1&offset=0' ,
853854 json = [response ],
854855 )
855856 mocked_responses .add (
@@ -969,3 +970,50 @@ def test_sync_stream_no_stream(
969970
970971 assert result .exit_code == 1
971972 assert 'Stream STR-7748-7021-7449 not found for the current account VA-000.' in result .output
973+
974+
975+ def test_sync_stream_active_stream (
976+ mocker ,
977+ ccli ,
978+ mocked_responses ,
979+ config_mocker ,
980+ load_stream_sync ,
981+ ):
982+ mocker .patch (
983+ 'connect.cli.plugins.commerce.utils.get_work_book' ,
984+ return_value = load_stream_sync ,
985+ )
986+ mocker .patch (
987+ 'connect.cli.plugins.commerce.utils.upload_attachment' ,
988+ return_value = {'id' : 'ID' },
989+ )
990+ mocked_responses .add (
991+ method = 'GET' ,
992+ url = 'https://localhost/public/v1/billing/streams?eq(id,STR-7748-7021-7449)&limit=0&offset=0' ,
993+ headers = {
994+ 'Content-Range' : 'items 0-1/1' ,
995+ },
996+ )
997+
998+ with open ('./tests/fixtures/commerce/stream_retrieve_response.json' ) as content :
999+ response = json .load (content )[0 ]
1000+ mocked_responses .add (
1001+ method = 'GET' ,
1002+ url = 'https://localhost/public/v1/billing/streams?eq(id,STR-7748-7021-7449)&select(context,samples,sources,validation)&limit=1&offset=0' ,
1003+ json = [response ],
1004+ )
1005+
1006+ runner = CliRunner ()
1007+ cmd = [
1008+ 'commerce' ,
1009+ 'stream' ,
1010+ 'sync' ,
1011+ 'STR-7748-7021-7449' ,
1012+ ]
1013+ result = runner .invoke (
1014+ ccli ,
1015+ cmd ,
1016+ )
1017+
1018+ assert result .exit_code == 1
1019+ assert 'Stream STR-7748-7021-7449 cannot be updated because it is in "active"' in result .output
0 commit comments