[MediaWiki-commits] [Gerrit] operations...pybal[master]: Add BGP.parse{KeepAlive, Notification} test cases

2017-08-09 Thread Ema (Code Review)
Ema has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356620 )

Change subject: Add BGP.parse{KeepAlive,Notification} test cases
..


Add BGP.parse{KeepAlive,Notification} test cases

Change-Id: I57c71ddd12fe0c9f271debd4dcbda99181025484
---
M pybal/bgp/test/test_bgp.py
1 file changed, 12 insertions(+), 0 deletions(-)

Approvals:
  Ema: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pybal/bgp/test/test_bgp.py b/pybal/bgp/test/test_bgp.py
index 5776ee6..c0131af 100644
--- a/pybal/bgp/test/test_bgp.py
+++ b/pybal/bgp/test/test_bgp.py
@@ -242,3 +242,15 @@
 msgdata = bytearray(bytes(update)[bgp.HDR_LEN:])
 msgdata[0] += 66
 self.assertRaises(Exception, self.proto.parseUpdate, msgdata)
+
+def testParseKeepAlive(self):
+self.assertRaises(bgp.BadMessageLength, self.proto.parseKeepAlive, b' 
')
+
+def testParseNotification(self):
+# Verify whether a valid NOTIFICATION parses correctly
+msg = (struct.pack('!BB', bgp.ERR_MSG_UPDATE,
+bgp.ERR_MSG_UPDATE_MALFORMED_ASPATH) + b"Unit test")
+self.assertEquals(self.proto.parseNotification(msg),
+(bgp.ERR_MSG_UPDATE, bgp.ERR_MSG_UPDATE_MALFORMED_ASPATH, b"Unit 
test"))
+# Verify a truncated message raises BadMessageLength
+self.assertRaises(bgp.BadMessageLength, self.proto.parseNotification, 
b' ')

-- 
To view, visit https://gerrit.wikimedia.org/r/356620
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I57c71ddd12fe0c9f271debd4dcbda99181025484
Gerrit-PatchSet: 6
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma 
Gerrit-Reviewer: Ema 
Gerrit-Reviewer: Giuseppe Lavagetto 
Gerrit-Reviewer: Volans 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations...pybal[master]: Add BGP.parse{KeepAlive, Notification} test cases

2017-06-01 Thread Mark Bergsma (Code Review)
Mark Bergsma has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356620 )

Change subject: Add BGP.parse{KeepAlive,Notification} test cases
..

Add BGP.parse{KeepAlive,Notification} test cases

Change-Id: I57c71ddd12fe0c9f271debd4dcbda99181025484
---
M pybal/bgp/test/test_bgp.py
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal 
refs/changes/20/356620/1

diff --git a/pybal/bgp/test/test_bgp.py b/pybal/bgp/test/test_bgp.py
index 309b2a1..34eba77 100644
--- a/pybal/bgp/test/test_bgp.py
+++ b/pybal/bgp/test/test_bgp.py
@@ -230,3 +230,13 @@
 msgdata = bytearray(bytes(update)[bgp.HDR_LEN:])
 msgdata[0] += 66
 self.assertRaises(Exception, self.proto.parseUpdate, msgdata)
+
+def testParseKeepAlive(self):
+self.assertRaises(bgp.BadMessageLength, self.proto.parseKeepAlive, b' 
')
+
+def testParseNotification(self):
+msg = (struct.pack('!BB', bgp.ERR_MSG_UPDATE,
+bgp.ERR_MSG_UPDATE_MALFORMED_ASPATH) + b"Unit test")
+self.assertEquals(self.proto.parseNotification(msg),
+(bgp.ERR_MSG_UPDATE, bgp.ERR_MSG_UPDATE_MALFORMED_ASPATH, b"Unit 
test"))
+self.assertRaises(bgp.BadMessageLength, self.proto.parseNotification, 
b' ')

-- 
To view, visit https://gerrit.wikimedia.org/r/356620
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I57c71ddd12fe0c9f271debd4dcbda99181025484
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits