"""dim_refresh.py file tests.""" from unittest.mock import patch from bin import dim_refresh @patch('bin.dim_refresh.subprocess') def test_execute_dim_flows(mock_subprocess): """Test execute_dim_flows() correctly unpacks contexts.""" catalog_downstream_context = [ dict( dim_type='catalog', downstream_contexts=[dict(dim_type='imprint')] ) ] dims = [ ('artist', None), ('release', dict(downstream_contexts=catalog_downstream_context)) ] with patch('bin.dim_refresh.DIMS', new=dims): dim_refresh.execute_dim_flows() mock_subprocess.check_call.assert_any_call( ['dim-refresh', 'refresh', 'exec', 'artist']) mock_subprocess.check_call.assert_any_call( [ 'dim-refresh', 'refresh', '-c', '{"downstream_contexts": [{"dim_type": "catalog",' ' "downstream_contexts": [{"dim_type": "imprint"}]}]}', 'exec', 'release' ] )