| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Unit tests data for the asynceapi client package.""" |
| 5 |
|
| 6 |
from asynceapi._constants import EapiCommandFormat |
| 7 |
from asynceapi._types import EapiJsonOutput, JsonRpc |
| 8 |
|
| 9 |
SUCCESS_EAPI_RESPONSE: EapiJsonOutput = { |
| 10 |
"jsonrpc": "2.0", |
| 11 |
"id": "EapiExplorer-1", |
| 12 |
"result": [ |
| 13 |
{ |
| 14 |
"mfgName": "Arista", |
| 15 |
"modelName": "cEOSLab", |
| 16 |
"hardwareRevision": "", |
| 17 |
"serialNumber": "5E9D49D20F09DA471333DD835835FD1A", |
| 18 |
"systemMacAddress": "00:1c:73:2e:7b:a3", |
| 19 |
"hwMacAddress": "00:00:00:00:00:00", |
| 20 |
"configMacAddress": "00:00:00:00:00:00", |
| 21 |
"version": "4.31.1F-34554157.4311F (engineering build)", |
| 22 |
"architecture": "i686", |
| 23 |
"internalVersion": "4.31.1F-34554157.4311F", |
| 24 |
"internalBuildId": "47114ca4-ae9f-4f32-8c1f-2864db93b7e8", |
| 25 |
"imageFormatVersion": "1.0", |
| 26 |
"imageOptimization": "None", |
| 27 |
"cEosToolsVersion": "(unknown)", |
| 28 |
"kernelVersion": "6.5.0-44-generic", |
| 29 |
"bootupTimestamp": 1723429239.9352903, |
| 30 |
"uptime": 1300202.749528885, |
| 31 |
"memTotal": 65832112, |
| 32 |
"memFree": 41610316, |
| 33 |
"isIntlVersion": False, |
| 34 |
}, |
| 35 |
{ |
| 36 |
"utcTime": 1724729442.6863558, |
| 37 |
"timezone": "EST", |
| 38 |
"localTime": { |
| 39 |
"year": 2024, |
| 40 |
"month": 8, |
| 41 |
"dayOfMonth": 26, |
| 42 |
"hour": 22, |
| 43 |
"min": 30, |
| 44 |
"sec": 42, |
| 45 |
"dayOfWeek": 0, |
| 46 |
"dayOfYear": 239, |
| 47 |
"daylightSavingsAdjust": 0, |
| 48 |
}, |
| 49 |
"clockSource": {"local": True}, |
| 50 |
}, |
| 51 |
], |
| 52 |
} |
| 53 |
"""Successful eAPI JSON response.""" |
| 54 |
|
| 55 |
ERROR_EAPI_RESPONSE: EapiJsonOutput = { |
| 56 |
"jsonrpc": "2.0", |
| 57 |
"id": "EapiExplorer-1", |
| 58 |
"error": { |
| 59 |
"code": 1002, |
| 60 |
"message": "CLI command 2 of 3 'bad command' failed: invalid command", |
| 61 |
"data": [ |
| 62 |
{ |
| 63 |
"mfgName": "Arista", |
| 64 |
"modelName": "cEOSLab", |
| 65 |
"hardwareRevision": "", |
| 66 |
"serialNumber": "5E9D49D20F09DA471333DD835835FD1A", |
| 67 |
"systemMacAddress": "00:1c:73:2e:7b:a3", |
| 68 |
"hwMacAddress": "00:00:00:00:00:00", |
| 69 |
"configMacAddress": "00:00:00:00:00:00", |
| 70 |
"version": "4.31.1F-34554157.4311F (engineering build)", |
| 71 |
"architecture": "i686", |
| 72 |
"internalVersion": "4.31.1F-34554157.4311F", |
| 73 |
"internalBuildId": "47114ca4-ae9f-4f32-8c1f-2864db93b7e8", |
| 74 |
"imageFormatVersion": "1.0", |
| 75 |
"imageOptimization": "None", |
| 76 |
"cEosToolsVersion": "(unknown)", |
| 77 |
"kernelVersion": "6.5.0-44-generic", |
| 78 |
"bootupTimestamp": 1723429239.9352903, |
| 79 |
"uptime": 1300027.2297976017, |
| 80 |
"memTotal": 65832112, |
| 81 |
"memFree": 41595080, |
| 82 |
"isIntlVersion": False, |
| 83 |
}, |
| 84 |
{"errors": ["Invalid input (at token 1: 'bad')"]}, |
| 85 |
], |
| 86 |
}, |
| 87 |
} |
| 88 |
"""Error eAPI JSON response.""" |
| 89 |
|
| 90 |
JSONRPC_REQUEST_TEMPLATE: JsonRpc = { |
| 91 |
"jsonrpc": "2.0", |
| 92 |
"method": "runCmds", |
| 93 |
"params": {"version": 1, "cmds": [], "format": EapiCommandFormat.JSON}, |
| 94 |
"id": "EapiExplorer-1", |
| 95 |
} |
| 96 |
"""Template for JSON-RPC eAPI request. `cmds` must be filled by the parametrize decorator.""" |