예제 #1
0
 def test_gui_wrong_max_allowed_freq(self):
     """Tests the response to a GUI request with an item for which the Max
     Allowed Frequency is of wrong type.
     """
     max_allowed_freq_values = [None, 4, "str", False]
     for freq in max_allowed_freq_values:
         items = [build_test_gui_item([Mode.COMMAND, Mode.RAW, Mode.MERGE],
                                      31, freq)]
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_get_user_item_data(items)
         self.assertEqual("Not a float value: '{}'".format(freq),
                          str(err.exception))
예제 #2
0
 def test_gui_wrong_buffer_size(self):
     """Tests the response to a GUI request with an item for which the
     Allowed Buffer Size is of wrong type.
     """
     allowed_buffer_size_values = [None, 4.5, "str", True]
     for buffer_size in allowed_buffer_size_values:
         items = [build_test_gui_item([Mode.COMMAND, Mode.RAW, Mode.MERGE],
                                      buffer_size, 24.5)]
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_get_user_item_data(items)
         self.assertEqual("Not an int value: '{}'".format(buffer_size),
                          str(err.exception))
 def execute():
     try:
         items = [{"allowedModeList":
                   [mode for mode in list(Mode)
                    if self._adapter.ismode_allowed(user, item, mode)],
                   "allowedBufferSize":
                   self._adapter.get_allowed_buffer_size(user, item),
                   "allowedMaxFrequency":
                   self._adapter.get_allowed_max_item_frequency(user,
                                                                item)}
                  for item in user_items]
     except Exception as err:
         res = meta_protocol.write_get_user_item_data(exception=err)
     else:
         res = meta_protocol.write_get_user_item_data(items)
     return res
예제 #4
0
 def test_gui_more_modes(self):
     """Tests the response to a GUI request with an item with more than only
     one Mode.
     """
     items = [build_test_gui_item([Mode.COMMAND, Mode.RAW, Mode.MERGE], 31,
                                  24.5)]
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual("GUI|I|31|D|24.5|M|CRM", res)
 def execute():
     try:
         items = [{
             "allowedModeList": [
                 mode for mode in list(Mode)
                 if self._adapter.ismode_allowed(user, item, mode)
             ],
             "allowedBufferSize":
             self._adapter.get_allowed_buffer_size(user, item),
             "allowedMaxFrequency":
             self._adapter.get_allowed_max_item_frequency(user, item)
         } for item in user_items]
     except Exception as err:
         res = meta_protocol.write_get_user_item_data(exception=err)
     else:
         res = meta_protocol.write_get_user_item_data(items)
     return res
예제 #6
0
 def test_gui_more(self):
     """Tests the response to a GUI request with a more than only one item.
     """
     items = [
         build_test_gui_item([Mode.COMMAND], 50, 56.0),
         build_test_gui_item([Mode.DISTINCT], 20, 61.71)
     ]
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual(("GUI" "|I|50|D|56.0|M|C" "|I|20|D|61.71|M|D"), res)
 def test_gui_more(self):
     """Tests the response to a GUI request with a more than only one item.
     """
     items = [build_test_gui_item([Mode.COMMAND], 50, 56.0),
              build_test_gui_item([Mode.DISTINCT], 20, 61.71)]
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual(("GUI"
                       "|I|50|D|56.0|M|C"
                       "|I|20|D|61.71|M|D"), res)
예제 #8
0
 def test_gui_generic_error(self):
     """Tests the response to a GUI request in case of a generic exception.
     """
     error = RuntimeError("Generic Error")
     res = metadata_protocol.write_get_user_item_data(exception=error)
     self.assertEqual("GUI|E|Generic+Error", res)
예제 #9
0
 def test_gui_one(self):
     """Tests the response to a GUI request with a single item."""
     items = [build_test_gui_item([Mode.COMMAND], 40, 56.0)]
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual("GUI|I|40|D|56.0|M|C", res)
예제 #10
0
 def test_gui_none(self):
     """Tests the response to a GUI request with a None list of items."""
     items = None
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual("GUI", res)
 def test_gui_generic_error(self):
     """Tests the response to a GUI request in case of a generic exception.
     """
     error = RuntimeError("Generic Error")
     res = metadata_protocol.write_get_user_item_data(exception=error)
     self.assertEqual("GUI|E|Generic+Error", res)
 def test_gui_one(self):
     """Tests the response to a GUI request with a single item."""
     items = [build_test_gui_item([Mode.COMMAND], 40, 56.0)]
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual("GUI|I|40|D|56.0|M|C", res)
 def test_gui_none(self):
     """Tests the response to a GUI request with a None list of items."""
     items = None
     res = metadata_protocol.write_get_user_item_data(items)
     self.assertEqual("GUI", res)