Exemplo n.º 1
0
    def test_make_message_publication_dataset_replica_ok(self):

        # Test variables
        args_dict = self.__get_args_dict_dataset()
        args_dict['is_replica'] = True

        # Run code to be tested:
        received_message = messages.publish_dataset(**args_dict)

        # Check result:
        expected = copy.deepcopy(args_dict)
        expected[
            'ROUTING_KEY'] = PREFIX_FOR_ROUTINGKEY + '.HASH.fresh.publi-ds-repli'
        expected['aggregation_level'] = 'dataset'
        expected['operation'] = 'publish'
        # Rename some:
        expected['handle'] = expected['dataset_handle']
        del expected['dataset_handle']
        expected['message_timestamp'] = expected['timestamp']
        del expected['timestamp']
        expected['files'] = expected['list_of_files']
        del expected['list_of_files']

        same = utils.is_json_same(expected, received_message)
        self.assertTrue(same, error_message(expected, received_message))
Exemplo n.º 2
0
    def test_make_message_publication_dataset_missing_args(self):

        # Test variables
        args_dict = self.__get_args_dict_dataset()

        # Run code to be tested:
        for k, v in args_dict.items():
            args = copy.deepcopy(args_dict)
            LOGGER.debug('Deleting %s and trying...', k)
            del args[k]
            with self.assertRaises(esgfpid.exceptions.ArgumentError):
                received_message = messages.publish_dataset(**args)