예제 #1
0
 def test_git_wrong_dist_snap_length(self):
     """Tests the response to a GIT request with an item for which the
     Distinct Snapshot Length is of a wrong type.
     """
     wrong_snapshot_length_values = [None, "str", 4.5, True]
     for length in wrong_snapshot_length_values:
         items = [build_test_git_item([Mode.COMMAND, Mode.RAW, Mode.MERGE],
                                      length, 4.5)]
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_get_item_data(items)
         self.assertEqual("Not an int value: '{}'".format(length),
                          str(err.exception))
예제 #2
0
 def test_git_wrong_min_source_freq(self):
     """Tests the response to a GITS request with an item for which the
     Min Source Frequency is of a wrong type.
     """
     # Min Source Frequency as a int (not as a float)
     wrong_freq_values = [4, "str", True]
     for freq in wrong_freq_values:
         items = [build_test_git_item([Mode.COMMAND, Mode.RAW, Mode.MERGE],
                                      3, freq)]
         with self.assertRaises(RemotingException) as err:
             metadata_protocol.write_get_item_data(items)
         self.assertEqual("Not a float value: '{}'".format(freq),
                          str(err.exception))
 def execute():
     try:
         items = [{"allowedModeList":
                   [mode for mode in list(Mode)
                    if self._adapter.mode_may_be_allowed(item, mode)],
                   "distinctSnapshotLength":
                   self._adapter.get_distinct_snapshot_length(item),
                   "minSourceFrequency":
                   self._adapter.get_min_source_frequency(item)}
                  for item in parsed_data]
     except Exception as err:
         res = meta_protocol.write_get_item_data(exception=err)
     else:
         res = meta_protocol.write_get_item_data(items)
     return res
예제 #4
0
 def test_git_more_modes(self):
     """Tests the response to a GIT request with an item with more than
     only one Mode.
     """
     items = [build_test_git_item([Mode.COMMAND, Mode.RAW, Mode.MERGE], 3,
                                  4.5)]
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual("GIT|I|3|D|4.5|M|CRM", res)
 def execute():
     try:
         items = [{
             "allowedModeList": [
                 mode for mode in list(Mode)
                 if self._adapter.mode_may_be_allowed(item, mode)
             ],
             "distinctSnapshotLength":
             self._adapter.get_distinct_snapshot_length(item),
             "minSourceFrequency":
             self._adapter.get_min_source_frequency(item)
         } for item in parsed_data]
     except Exception as err:
         res = meta_protocol.write_get_item_data(exception=err)
     else:
         res = meta_protocol.write_get_item_data(items)
     return res
예제 #6
0
 def test_git_more(self):
     """Tests the response to a GIT request with a more than only one item.
     """
     items = [
         build_test_git_item([Mode.COMMAND], 3, 4.5),
         build_test_git_item([Mode.DISTINCT], 1, 6.7)
     ]
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual(("GIT" "|I|3|D|4.5|M|C" "|I|1|D|6.7|M|D"), res)
 def test_git_more(self):
     """Tests the response to a GIT request with a more than only one item.
     """
     items = [build_test_git_item([Mode.COMMAND], 3, 4.5),
              build_test_git_item([Mode.DISTINCT], 1, 6.7)]
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual(("GIT"
                       "|I|3|D|4.5|M|C"
                       "|I|1|D|6.7|M|D"), res)
예제 #8
0
 def test_git_generic_error(self):
     """Tests the response to a GIT request in case of a generic exception.
     """
     error = RuntimeError("Generic Error")
     res = metadata_protocol.write_get_item_data(exception=error)
     self.assertEqual("GIT|E|Generic+Error", res)
예제 #9
0
 def test_git_one(self):
     """Tests the response to a GIT request with a single item."""
     items = [build_test_git_item([Mode.COMMAND], 3, 4.5)]
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual("GIT|I|3|D|4.5|M|C", res)
예제 #10
0
 def test_git_none(self):
     """Tests the response to a GIT request with a None list of items."""
     items = None
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual("GIT", res)
 def test_git_generic_error(self):
     """Tests the response to a GIT request in case of a generic exception.
     """
     error = RuntimeError("Generic Error")
     res = metadata_protocol.write_get_item_data(exception=error)
     self.assertEqual("GIT|E|Generic+Error", res)
 def test_git_one(self):
     """Tests the response to a GIT request with a single item."""
     items = [build_test_git_item([Mode.COMMAND], 3, 4.5)]
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual("GIT|I|3|D|4.5|M|C", res)
 def test_git_none(self):
     """Tests the response to a GIT request with a None list of items."""
     items = None
     res = metadata_protocol.write_get_item_data(items)
     self.assertEqual("GIT", res)