-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_fbsp.py
More file actions
108 lines (100 loc) · 3.5 KB
/
test_fbsp.py
File metadata and controls
108 lines (100 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# SPDX-FileCopyrightText: 2018-present Pavel Cisar <pcisar@users.sourceforge.net>
#
# SPDX-License-Identifier: MIT
"""
ID: butler-fbsp-protobuf
TITLE: FDSP protobuf
DESCRIPTION:
NOTES:
"""
import pytest
import uuid
import firebird.butler.fbsd_pb2 as fbsd
import firebird.butler.fbsp_pb2 as fbsp
_PEER_UID = uuid.uuid1().bytes
_PID = 100
_HOST = 'host'
_AGENT_UID = uuid.uuid1().bytes
_NAME = 'Agent name'
_AGENT_VERSION = 'agent version'
_VENDOR_ID = uuid.uuid1().bytes
_PLATFORM_ID = uuid.uuid1().bytes
_PLATFORM_VERSION = 'platform version'
_CLASSIFICATION = 'classification'
_API_1_NUM = 1
_API_1_ID = uuid.uuid1().bytes
_API_2_NUM = 2
_API_2_ID = uuid.uuid1().bytes
_STATE = fbsd.STATE_RUNNING
def test_FBSPHelloDataframe():
proto = fbsp.FBSPHelloDataframe()
proto.instance.uid = _PEER_UID
proto.instance.host = _HOST
proto.instance.pid = _PID
proto.client.uid = _AGENT_UID
proto.client.name = _NAME
proto.client.version = _AGENT_VERSION
proto.client.vendor.uid = _VENDOR_ID
proto.client.platform.uid = _PLATFORM_ID
proto.client.platform.version = _PLATFORM_VERSION
proto.client.classification = _CLASSIFICATION
msg = proto.SerializeToString()
proto.Clear()
proto.ParseFromString(msg)
assert proto.instance.uid == _PEER_UID
assert proto.instance.host == _HOST
assert proto.instance.pid == _PID
assert proto.client.uid == _AGENT_UID
assert proto.client.name == _NAME
assert proto.client.version == _AGENT_VERSION
assert proto.client.vendor.uid == _VENDOR_ID
assert proto.client.platform.uid == _PLATFORM_ID
assert proto.client.platform.version == _PLATFORM_VERSION
assert proto.client.classification == _CLASSIFICATION
def test_FBSPWelcomeDataframe():
proto = fbsp.FBSPWelcomeDataframe()
proto.instance.uid = _PEER_UID
proto.instance.host = _HOST
proto.instance.pid = _PID
proto.service.uid = _AGENT_UID
proto.service.name = _NAME
proto.service.version = _AGENT_VERSION
proto.service.vendor.uid = _VENDOR_ID
proto.service.platform.uid = _PLATFORM_ID
proto.service.platform.version = _PLATFORM_VERSION
proto.service.classification = _CLASSIFICATION
api1 = fbsd.InterfaceSpec(number=_API_1_NUM, uid=_API_1_ID)
api2 = fbsd.InterfaceSpec(number=_API_2_NUM, uid=_API_2_ID)
proto.api.extend([api1, api2])
msg = proto.SerializeToString()
proto.Clear()
proto.ParseFromString(msg)
assert proto.instance.uid == _PEER_UID
assert proto.instance.host == _HOST
assert proto.instance.pid == _PID
assert proto.service.uid == _AGENT_UID
assert proto.service.name == _NAME
assert proto.service.version == _AGENT_VERSION
assert proto.service.vendor.uid == _VENDOR_ID
assert proto.service.platform.uid == _PLATFORM_ID
assert proto.service.platform.version == _PLATFORM_VERSION
assert proto.service.classification == _CLASSIFICATION
assert len(proto.api) == 2
assert proto.api[0].number == api1.number
assert proto.api[0].uid == api1.uid
assert proto.api[1].number == api2.number
assert proto.api[1].uid == api2.uid
def test_FBSPCancelRequests():
proto = fbsp.FBSPCancelRequests()
proto.token = _PEER_UID
msg = proto.SerializeToString()
proto.Clear()
proto.ParseFromString(msg)
assert proto.token == _PEER_UID
def test_FBSPStateInformation():
proto = fbsp.FBSPStateInformation()
proto.state = _STATE
msg = proto.SerializeToString()
proto.Clear()
proto.ParseFromString(msg)
assert proto.state == _STATE