2525from  cylc .flow .network  import  ZMQSocketBase 
2626from  cylc .flow .workflow_files  import  ContactFileFields  as  CFF 
2727
28- from  cylc .uiserver .data_store_mgr  import  DataStoreMgr 
28+ from  cylc .uiserver .data_store_mgr  import  (
29+     DataStoreMgr ,
30+     MAX_LEVEL ,
31+     SUBSCRIPTION_LEVELS 
32+ )
2933
3034from  .conftest  import  AsyncClientFixture 
3135
3236
33- async  def  test_entire_workflow_update (
37+ async  def  test_workflow_update (
3438    async_client : AsyncClientFixture ,
3539    data_store_mgr : DataStoreMgr ,
3640    make_entire_workflow 
3741):
38-     """Test that ``entire_workflow_update `` is executed successfully.""" 
42+     """Test that ``_workflow_update `` is executed successfully.""" 
3943    w_id  =  'workflow_id' 
4044    entire_workflow  =  make_entire_workflow (f'{ w_id }  ' )
4145    async_client .will_return (entire_workflow .SerializeToString ())
@@ -45,10 +49,13 @@ async def test_entire_workflow_update(
4549        'req_client' : async_client 
4650    }
4751
48-     # Call the entire_workflow_update  function. 
52+     # Call the _workflow_update  function. 
4953    # This should use the client defined above (``async_client``) when 
5054    # calling ``workflow_request``. 
51-     await  data_store_mgr ._entire_workflow_update ()
55+     await  data_store_mgr ._workflow_update (
56+         [w_id ],
57+         SUBSCRIPTION_LEVELS [MAX_LEVEL ]["request" ]
58+     )
5259
5360    # The ``DataStoreMgr`` sets the workflow data retrieved in its 
5461    # own ``.data`` dictionary, which will contain Protobuf message 
@@ -61,12 +68,12 @@ async def test_entire_workflow_update(
6168    assert  entire_workflow .workflow .id  ==  w_id_data ['workflow' ].id 
6269
6370
64- async  def  test_entire_workflow_update_ignores_timeout_message (
71+ async  def  test_workflow_update_ignores_timeout_message (
6572    async_client : AsyncClientFixture ,
6673    data_store_mgr : DataStoreMgr 
6774):
6875    """ 
69-     Test that ``entire_workflow_update `` ignores if the client 
76+     Test that ``_workflow_update `` ignores if the client 
7077    receives a ``MSG_TIMEOUT`` message. 
7178    """ 
7279    w_id  =  'workflow_id' 
@@ -77,24 +84,27 @@ async def test_entire_workflow_update_ignores_timeout_message(
7784        'req_client' : async_client 
7885    }
7986
80-     # Call the entire_workflow_update  function. 
87+     # Call the _workflow_update  function. 
8188    # This should use the client defined above (``async_client``) when 
8289    # calling ``workflow_request``. 
83-     await  data_store_mgr ._entire_workflow_update ()
90+     await  data_store_mgr ._workflow_update (
91+         [w_id ],
92+         SUBSCRIPTION_LEVELS [MAX_LEVEL ]["request" ]
93+     )
8494
8595    # When a ClientTimeout happens, the ``DataStoreMgr`` object ignores 
8696    # that message. So it means that its ``.data`` dictionary MUST NOT 
8797    # have an entry for the Workflow ID. 
8898    assert  w_id  not  in   data_store_mgr .data 
8999
90100
91- async  def  test_entire_workflow_update_gather_error (
101+ async  def  test_workflow_update_gather_error (
92102    async_client : AsyncClientFixture ,
93103    data_store_mgr : DataStoreMgr ,
94104    caplog : pytest .LogCaptureFixture ,
95105):
96106    """ 
97-     Test that if ``asyncio.gather`` in ``entire_workflow_update `` 
107+     Test that if ``asyncio.gather`` in ``_workflow_update `` 
98108    has a coroutine raising an error, it will handle the error correctly. 
99109    """ 
100110    # The ``AsyncClient`` will raise an error. This will happen when 
@@ -110,10 +120,13 @@ async def test_entire_workflow_update_gather_error(
110120        'req_client' : async_client 
111121    }
112122
113-     # Call the entire_workflow_update  function. 
123+     # Call the _workflow_update  function. 
114124    # This should use the client defined above (``async_client``) when 
115125    # calling ``workflow_request``. 
116-     await  data_store_mgr ._entire_workflow_update ()
126+     await  data_store_mgr ._workflow_update (
127+         ['workflow_id' ],
128+         SUBSCRIPTION_LEVELS [MAX_LEVEL ]["request" ]
129+     )
117130    assert  caplog .record_tuples  ==  [
118131        ('cylc' , 40 , 'Error communicating with myflow' ),
119132        ('cylc' , 40 , 'x' ),
@@ -124,19 +137,22 @@ async def test_entire_workflow_update_gather_error(
124137    assert  exc_info  and  exc_info [0 ] ==  ValueError 
125138
126139
127- async  def  test_entire_workflow_update__stopped_workflow (
140+ async  def  test_workflow_update__stopped_workflow (
128141    async_client : AsyncClientFixture ,
129142    data_store_mgr : DataStoreMgr ,
130143    caplog : pytest .LogCaptureFixture ,
131144):
132-     """Test that DataStoreMgr._entire_workflow_update () handles a stopped 
145+     """Test that DataStoreMgr._workflow_update () handles a stopped 
133146    workflow reasonably.""" 
134147    exc  =  WorkflowStopped ('myflow' )
135148    async_client .will_return (exc )
136149    data_store_mgr .workflows_mgr .workflows ['workflow_id' ] =  {
137150        'req_client' : async_client 
138151    }
139-     await  data_store_mgr ._entire_workflow_update ()
152+     await  data_store_mgr ._workflow_update (
153+         ['workflow_id' ],
154+         SUBSCRIPTION_LEVELS [MAX_LEVEL ]["request" ]
155+     )
140156    assert  caplog .record_tuples  ==  [
141157        ('cylc' , 40 , f'WorkflowStopped: { exc }  ' ),
142158    ]
0 commit comments