예제 #1
0
 def test_nus_wrong_max_bandwidth(self):
     """Tests the response to a NUS request in case of the Allowed Max
     Bandwidth is of a wrong type.
     """
     method = metadata_protocol.Method.NUS
     allowed_max_bandwidth_values = [None, 4, "str", False]
     for band_width in allowed_max_bandwidth_values:
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_notiy_user(method, band_width, True)
         self.assertEqual("Not a float value: '{}'".format(band_width),
                          str(err.exception))
예제 #2
0
 def test_nus_wrong_wants_tab_notif(self):
     """Tests the response to a NUS request in case of the Wants Table
     Notification is of a wrong type.
     """
     method = metadata_protocol.Method.NUS
     wants_table_notification_values = [None, 4, "str", 4.5]
     for wants_notif in wants_table_notification_values:
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_notiy_user(method, 4.5, wants_notif)
         self.assertEqual("Not a bool value: '{}'".format(wants_notif),
                          str(err.exception))
 def test_nus_wrong_wants_tab_notif(self):
     """Tests the response to a NUS request in case of the Wants Table
     Notification is of a wrong type.
     """
     method = metadata_protocol.Method.NUS
     wants_table_notification_values = [None, 4, "str", 4.5]
     for wants_notif in wants_table_notification_values:
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_notiy_user(method,
                                                4.5,
                                                wants_notif)
         self.assertEqual("Not a bool value: '{}'".format(wants_notif),
                          str(err.exception))
 def test_nus_wrong_max_bandwidth(self):
     """Tests the response to a NUS request in case of the Allowed Max
     Bandwidth is of a wrong type.
     """
     method = metadata_protocol.Method.NUS
     allowed_max_bandwidth_values = [None, 4, "str", False]
     for band_width in allowed_max_bandwidth_values:
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_notiy_user(method,
                                                band_width,
                                                True)
         self.assertEqual("Not a float value: '{}'".format(band_width),
                          str(err.exception))
 def execute():
     try:
         self._adapter.notify_user(user, password, http_headers)
         max_bandwidth = self._adapter.get_allowed_max_bandwidth(user)
         wants_tb_ntf = self._adapter.wants_tables_notification(user)
     except Exception as err:
         res = meta_protocol.write_notiy_user(meta_protocol.Method.NUS,
                                              exception=err)
     else:
         res = meta_protocol.write_notiy_user(meta_protocol.Method.NUS,
                                              max_bandwidth,
                                              wants_tb_ntf)
     return res
 def execute():
     try:
         self._adapter.notify_user(user, password, http_headers)
         max_bandwidth = self._adapter.get_allowed_max_bandwidth(user)
         wants_tb_ntf = self._adapter.wants_tables_notification(user)
     except Exception as err:
         res = meta_protocol.write_notiy_user(meta_protocol.Method.NUS,
                                              exception=err)
     else:
         res = meta_protocol.write_notiy_user(meta_protocol.Method.NUS,
                                              max_bandwidth,
                                              wants_tb_ntf)
     return res
예제 #7
0
 def test_nus(self):
     """Tests the response to a NUS request."""
     allowed_max_bandwidth = 1.0
     wants_tables_notification = False
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUS,
                                              allowed_max_bandwidth,
                                              wants_tables_notification)
     self.assertEqual("NUS|D|1.0|B|0", res)
예제 #8
0
 def test_nua(self):
     """Tests the response to a NUA request."""
     allowed_max_bandwidth = 1.45
     wants_tables_notification = True
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUA,
                                              allowed_max_bandwidth,
                                              wants_tables_notification)
     self.assertEqual("NUA|D|1.45|B|1", res)
 def test_nus(self):
     """Tests the response to a NUS request."""
     allowed_max_bandwidth = 1.0
     wants_tables_notification = False
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUS,
                                              allowed_max_bandwidth,
                                              wants_tables_notification)
     self.assertEqual("NUS|D|1.0|B|0", res)
 def test_nua(self):
     """Tests the response to a NUA request."""
     allowed_max_bandwidth = 1.45
     wants_tables_notification = True
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUA,
                                              allowed_max_bandwidth,
                                              wants_tables_notification)
     self.assertEqual("NUA|D|1.45|B|1", res)
예제 #11
0
 def test_nus_credits_error(self):
     """Tests the response to a NNS request in case of a CreditsError."""
     error = CreditsError(14, "Credits Error")
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUS,
                                              exception=error)
     self.assertEqual("NUS|EC|Credits+Error|14|#", res)
예제 #12
0
 def test_nus_access_error(self):
     """Tests the response to a NNS request in case of a AccessError."""
     error = AccessError("Access Error")
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUS,
                                              exception=error)
     self.assertEqual("NUS|EA|Access+Error", res)
 def test_nus_credits_error(self):
     """Tests the response to a NNS request in case of a CreditsError."""
     error = CreditsError(14, "Credits Error")
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUS,
                                              exception=error)
     self.assertEqual("NUS|EC|Credits+Error|14|#", res)
 def test_nus_access_error(self):
     """Tests the response to a NNS request in case of a AccessError."""
     error = AccessError("Access Error")
     res = metadata_protocol.write_notiy_user(metadata_protocol.Method.NUS,
                                              exception=error)
     self.assertEqual("NUS|EA|Access+Error", res)