Skip to content

Commit e38c456

Browse files
committed
add tests
1 parent 444adac commit e38c456

1 file changed

Lines changed: 10 additions & 20 deletions

File tree

tests/scripts/test_create_teams.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import OrderedDict
22
from json.decoder import JSONDecodeError
3-
from unittest.mock import patch
3+
from unittest.mock import patch, Mock
44

55
import pytest
66
from faker import Faker
@@ -115,23 +115,13 @@ def test_process_teams(label, existing_teams_indexes, asset_indexes, data, len_e
115115
assert len(teams_to_delete) == len_expected_teams_to_delete
116116

117117

118-
def test_update_assets(organization):
118+
def test_update_assets(data):
119119
# 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

Comments
 (0)