Coverage for fio_wrapper/models/group_models.py: 100%

184 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-16 11:50 +0100

1from typing import List, Optional 

2from datetime import datetime, timedelta 

3from pydantic import BaseModel, RootModel, Field, AwareDatetime, NaiveDatetime 

4 

5 

6class GroupAdmin(BaseModel): 

7 GroupAdminUserName: str 

8 

9 

10class GroupUser(BaseModel): 

11 GroupUserName: str 

12 

13 

14class Group(BaseModel): 

15 GroupAdmins: List[GroupAdmin] 

16 GroupUsers: List[GroupUser] 

17 GroupModelId: int 

18 GroupOwner: str 

19 GroupName: str 

20 

21 def users(self) -> List[str]: 

22 return [user.GroupUserName.upper() for user in self.GroupUsers] 

23 

24 

25class GroupList(RootModel): 

26 root: List[Group] 

27 

28 def __iter__(self): 

29 """Iterates through all Groups 

30 

31 Returns: 

32 Group: Group element 

33 """ 

34 return iter(self.root) 

35 

36 def ids(self) -> List[int]: 

37 """Returns a list of Group IDs from all Groups in the List 

38 

39 Returns: 

40 List[int]: List of GroupModelId 

41 """ 

42 return [group.GroupModelId for group in self.root] 

43 

44 

45class GroupMembership(BaseModel): 

46 GroupName: str 

47 GroupId: int 

48 

49 

50class GroupMembershipList(RootModel): 

51 root: List[GroupMembership] 

52 

53 def __iter__(self): 

54 """Iterates through all group memberships 

55 

56 Returns: 

57 GroupMembership: Group membership element 

58 """ 

59 return iter(self.root) 

60 

61 def ids(self) -> List[int]: 

62 """Returns a list of Group IDs from all Group Memberships 

63 

64 Returns: 

65 List[int]: List of GroupIDs 

66 """ 

67 return [membership.GroupId for membership in self.root] 

68 

69 

70class StorageItem(BaseModel): 

71 MaterialTicker: Optional[str] = Field(max_length=3) 

72 MaterialName: Optional[str] 

73 MaterialCategoryName: Optional[str] 

74 Units: int 

75 

76 

77class PlayerCXWarehouses(BaseModel): 

78 PlayerName: str 

79 StorageType: str 

80 Items: List[StorageItem] 

81 

82 

83class CXWarehouse(BaseModel): 

84 WarehouseLocationName: str 

85 WarehouseLocationNaturalId: str 

86 PlayerCXWarehouses: List[PlayerCXWarehouses] 

87 

88 

89class RepairMaterial(BaseModel): 

90 MaterialTicker: str = Field(max_length=3) 

91 Amount: int 

92 

93 

94class AddressLine(BaseModel): 

95 LineId: str = Field(min_length=32) 

96 LineType: str 

97 NaturalId: str 

98 Name: str 

99 

100 

101class AddressLineFlight(BaseModel): 

102 LineId: str = Field(min_length=32) 

103 Type: str 

104 LineNaturalId: str 

105 LineName: str 

106 

107 

108class ShipFuel(BaseModel): 

109 CurrentSF: int 

110 MaxSF: int 

111 CurrentFF: int 

112 MaxFF: int 

113 

114 

115class ShipCargo(BaseModel): 

116 PlayerName: str 

117 StorageType: str 

118 Items: List[StorageItem] 

119 LastUpdated: NaiveDatetime 

120 

121 

122class ShipFlightSegment(BaseModel): 

123 OriginLines: List[AddressLineFlight] 

124 DestinationLines: List[AddressLineFlight] 

125 

126 Type: str 

127 DepartureTimeEpochMs: datetime 

128 ArrivalTimeEpochMs: datetime 

129 StlDistance: Optional[float] 

130 StlFuelConsumption: Optional[float] 

131 FtlDistance: Optional[float] 

132 FtlFuelConsumption: Optional[float] 

133 Origin: str 

134 Destination: str 

135 

136 

137class ShipFlight(BaseModel): 

138 Segments: List[ShipFlightSegment] 

139 

140 FlightId: str = Field(min_length=32) 

141 ShipId: str = Field(min_length=32) 

142 Origin: str 

143 Destination: str 

144 DepartureTimeEpochMs: datetime 

145 ArrivalTimeEpochMs: datetime 

146 CurrentSegmentIndex: int 

147 StlDistance: float 

148 FtlDistance: float 

149 IsAborted: bool 

150 Timestamp: NaiveDatetime 

151 

152 

153class PlayerShip(BaseModel): 

154 PlayerName: str 

155 ShipName: Optional[str] 

156 ShipRegistration: str 

157 Location: str 

158 Destination: Optional[str] 

159 LocationETA: Optional[AwareDatetime] 

160 LocationETALocalTime: Optional[AwareDatetime] 

161 Condition: float 

162 

163 RepairMaterials: List[RepairMaterial] 

164 AddressLines: List[AddressLine] 

165 

166 Flight: Optional[ShipFlight] 

167 Fuel: ShipFuel 

168 Cargo: ShipCargo 

169 

170 LastUpdated: NaiveDatetime 

171 

172 

173class Currency(BaseModel): 

174 CurrencyName: str 

175 Amount: float 

176 LastUpdated: NaiveDatetime 

177 

178 

179class Material(BaseModel): 

180 MaterialTicker: str = Field(max_length=3) 

181 MaterialName: str 

182 MaterialCategoryName: Optional[str] 

183 Units: int 

184 

185 

186class ProductionLine(BaseModel): 

187 Started: bool 

188 Halted: bool 

189 Recurring: bool 

190 OrderDuration: timedelta 

191 TimeCompletion: NaiveDatetime 

192 Inputs: List[Material] 

193 Outputs: List[Material] 

194 LastUpdated: NaiveDatetime 

195 BuildingName: str 

196 BuildingTicker: str = Field(max_length=3) 

197 Capacity: int 

198 Efficiency: float 

199 Condition: float 

200 

201 

202class Building(BaseModel): 

203 BuildingName: str 

204 BuildingTicker: str = Field(max_length=3) 

205 Condition: float 

206 RepairMaterials: List[Material] 

207 ReclaimableMaterials: List[Material] 

208 ProductionLiness: List[ProductionLine] 

209 

210 

211class Storage(BaseModel): 

212 PlayerName: str 

213 StorageType: str 

214 Items: List[Material] 

215 LastUpdated: NaiveDatetime 

216 

217 

218class Location(BaseModel): 

219 LocationIdentifier: str 

220 LocationName: str 

221 Buildings: List[Building] 

222 BaseStorage: Storage 

223 WarehouseStorage: Storage 

224 StationaryPlayerShips: List[PlayerShip] 

225 

226 

227class PlayerModel(BaseModel): 

228 Username: str 

229 Currencies: List[Currency] 

230 Locations: List[Location] 

231 

232 

233class GroupHub(BaseModel): 

234 GroupName: Optional[str] 

235 CXWarehouses: List[CXWarehouse] 

236 PlayerShipsInFlight: List[PlayerShip] 

237 PlayerStationaryShips: List[PlayerShip] 

238 Failures: List[str] 

239 

240 

241class Inventory(BaseModel): 

242 MaterialId: str = Field(min_length=32) 

243 MaterialTicker: Optional[str] = Field(max_length=3) 

244 MaterialAmount: int 

245 

246 

247class Consumption(BaseModel): 

248 MaterialId: str = Field(min_length=32) 

249 MaterialTicker: str = Field(max_length=3) 

250 DailyAmount: float 

251 

252 

253class Burn(BaseModel): 

254 RequesterUserName: str 

255 UserName: str 

256 Error: Optional[str] 

257 PlanetId: Optional[str] = Field(min_length=32) 

258 PlanetName: Optional[str] 

259 PlanetNaturalId: Optional[str] 

260 PlanetConsumptionTime: Optional[NaiveDatetime] 

261 LastUpdate: NaiveDatetime 

262 LastUpdateCause: Optional[str] 

263 

264 Inventory: List[Inventory] 

265 WorkforceConsumption: List[Consumption] 

266 OrderConsumption: List[Consumption] 

267 OrderProduction: List[Consumption] 

268 

269 

270class BurnList(RootModel): 

271 root: List[Burn] 

272 

273 def __iter__(self): 

274 """Iterates through all burn elements 

275 

276 Returns: 

277 Burn: Burn element 

278 """ 

279 return iter(self.root)