示例#1
0
 def test_parse_pdu_failure(self):
     connection = Connection(uuid.uuid4(), "server", 445)
     session = Session(connection, "user", "password")
     api = SCMRApi(session)
     fault_pdu = FaultPDU()
     fault_pdu['packed_drep'] = DataRepresentationFormat()
     with pytest.raises(PDUException) as exc:
         api._parse_pdu(fault_pdu.pack(), 10)
     assert "Expecting ResponsePDU for opnum 10 response but got: " \
            "FaultPDU" in str(exc.value)
示例#2
0
 def test_parse_pdu_fine(self):
     connection = Connection(uuid.uuid4(), "server", 445)
     session = Session(connection, "user", "password")
     api = SCMRApi(session)
     response_pdu = ResponsePDU()
     response_pdu['packed_drep'] = DataRepresentationFormat()
     response_pdu['stub_data'] = b"\x01\x02\x03\x04"
     expected = b"\x01\x02\x03\x04"
     actual = api._parse_pdu(response_pdu.pack(), 10)
     assert actual == expected