1010 AllowedStatus ,
1111 BannedStatus ,
1212 ComputeElementStatus ,
13+ FTSStatus ,
1314 StorageElementStatus ,
1415 map_status ,
1516)
@@ -76,17 +77,14 @@ async def test_site_status(rss_db: ResourceStatusDB):
7677 assert bool (result .all ) is True
7778
7879 # Test with an unknow Site (should not be found)
79- async with rss_db as rss_db :
80- result = await rss_db .get_site_status ("UnknownSite" )
81- assert isinstance (result , SiteStatusModel )
82- assert isinstance (result .all , BannedStatus )
83- assert bool (result .all ) is False
84- assert result .all .reason == "Not found"
80+ with pytest .raises (ValueError , match = "Site Unknown not found" ):
81+ async with rss_db as rss_db :
82+ await rss_db .get_site_status ("Unknown" )
8583
8684
87- async def test_compute_status (rss_db : ResourceStatusDB ):
88- # Insert a test Compute Element
85+ async def test_resource_status (rss_db : ResourceStatusDB ):
8986 async with rss_db .engine .begin () as conn :
87+ # Insert a test Compute Element
9088 await conn .execute (
9189 insert (rss_db .metadata .tables ["ResourceStatus" ]).values (
9290 Name = "TestCompute" ,
@@ -101,21 +99,60 @@ async def test_compute_status(rss_db: ResourceStatusDB):
10199 TokenOwner = "test" ,
102100 )
103101 )
102+ # Insert a test FTS
103+ await conn .execute (
104+ insert (rss_db .metadata .tables ["ResourceStatus" ]).values (
105+ Name = "TestFTS" ,
106+ StatusType = "all" ,
107+ VO = "all" ,
108+ Status = "Active" ,
109+ Reason = "All good" ,
110+ DateEffective = _NOW ,
111+ TokenExpiration = _FAR ,
112+ LastCheckTime = _NOW ,
113+ ElementType = "FTS" ,
114+ TokenOwner = "test" ,
115+ )
116+ )
117+ # Insert a wrong test
118+ await conn .execute (
119+ insert (rss_db .metadata .tables ["ResourceStatus" ]).values (
120+ Name = "WrongTest" ,
121+ StatusType = "all" ,
122+ VO = "all" ,
123+ Status = "Active" ,
124+ Reason = "All good" ,
125+ DateEffective = _NOW ,
126+ TokenExpiration = _FAR ,
127+ LastCheckTime = _NOW ,
128+ ElementType = "WrongTest" ,
129+ TokenOwner = "WrongTest" ,
130+ )
131+ )
104132
105133 # Test with the test Compute Element (should be found)
106134 async with rss_db as rss_db :
107- result = await rss_db .get_compute_status ("TestCompute" )
135+ result = await rss_db .get_resource_status ("TestCompute" )
108136 assert isinstance (result , ComputeElementStatus )
109137 assert isinstance (result .all , AllowedStatus )
110138 assert bool (result .all ) is True
111139
112- # Test with an unknow Compute Element (should not be found)
140+ # Test with the test FTS (should be found)
113141 async with rss_db as rss_db :
114- result = await rss_db .get_compute_status ("UnknownCompute" )
115- assert isinstance (result , ComputeElementStatus )
116- assert isinstance (result .all , BannedStatus )
117- assert bool (result .all ) is False
118- assert result .all .reason == "Not found"
142+ result = await rss_db .get_resource_status ("TestFTS" )
143+ assert isinstance (result , FTSStatus )
144+ assert isinstance (result .all , AllowedStatus )
145+ assert bool (result .all ) is True
146+
147+ # Test with a wrong Resource type
148+ with pytest .raises (ValueError , match = "not a valid ResourceType" ):
149+ async with rss_db as rss_db :
150+ await rss_db .get_resource_status ("WrongTest" )
151+
152+ # Test with an unknow Resource (should not be found)
153+ with pytest .raises (ValueError , match = "Resource Unknown not found" ):
154+ async with rss_db as rss_db :
155+ await rss_db .get_resource_status ("Unknown" )
119156
120157
121158async def test_storage_status (rss_db : ResourceStatusDB ):
@@ -151,18 +188,6 @@ async def test_storage_status(rss_db: ResourceStatusDB):
151188 assert bool (result .remove ) is True
152189
153190 # Test with an unknow Storage Element (should not be found)
154- async with rss_db as rss_db :
155- result = await rss_db .get_storage_status ("UnknownStorage" )
156- assert isinstance (result , StorageElementStatus )
157- assert isinstance (result .read , BannedStatus )
158- assert isinstance (result .write , BannedStatus )
159- assert isinstance (result .check , BannedStatus )
160- assert isinstance (result .remove , BannedStatus )
161- assert bool (result .read ) is False
162- assert bool (result .write ) is False
163- assert bool (result .check ) is False
164- assert bool (result .remove ) is False
165- assert result .read .reason == "Not found"
166- assert result .write .reason == "Not found"
167- assert result .check .reason == "Not found"
168- assert result .remove .reason == "Not found"
191+ with pytest .raises (ValueError , match = "StorageElement Unknown not found" ):
192+ async with rss_db as rss_db :
193+ await rss_db .get_storage_status ("Unknown" )
0 commit comments