|
1 | 1 | from collections import OrderedDict |
2 | 2 | from json.decoder import JSONDecodeError |
3 | | -from unittest.mock import patch |
| 3 | +from unittest.mock import patch, Mock |
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 | from faker import Faker |
@@ -115,23 +115,13 @@ def test_process_teams(label, existing_teams_indexes, asset_indexes, data, len_e |
115 | 115 | assert len(teams_to_delete) == len_expected_teams_to_delete |
116 | 116 |
|
117 | 117 |
|
118 | | -def test_update_assets(organization): |
| 118 | +def test_update_assets(data): |
119 | 119 | # Test with no assets |
120 | | - with patch("src.scripts.create_teams.list_assets") as mock_list_assets: |
121 | | - mock_list_assets.return_value = [] |
122 | | - update_assets("token", organization) |
123 | | - |
124 | | - # Test with some assets |
125 | | - with patch("src.scripts.create_teams.list_assets") as mock_list_assets: |
126 | | - mock_list_assets.return_value = [ |
127 | | - TeamStructure(name="team1", members=[], resources=[]), |
128 | | - TeamStructure(name="team2", members=[], resources=[]), |
129 | | - ] |
130 | | - with patch("src.scripts.create_teams.get_teams_for_assets") as mock_get_teams_for_assets: |
131 | | - mock_get_teams_for_assets.return_value = { |
132 | | - "asset1": ["team1"], |
133 | | - "asset2": ["team1", "team2"], |
134 | | - } |
135 | | - with patch("src.scripts.create_teams.add_teams_to_asset") as mock_add_teams_to_asset: |
136 | | - update_assets("token", organization) |
137 | | - assert mock_add_teams_to_asset.call_count == 2 |
| 120 | + organization, assets, teams = data |
| 121 | + # with patch("src.scripts.create_teams.list_assets") as mock_list_assets: |
| 122 | + # mock_list_assets.return_value = [] |
| 123 | + with patch("src.scripts.create_teams.add_teams_to_asset") as mock_add_teams_to_asset: |
| 124 | + update_assets("token", assets, organization) |
| 125 | + assert mock_add_teams_to_asset.call_count == 10 |
| 126 | + |
| 127 | + |
0 commit comments