Example #1
0
    def test_Uploadevent(self):
        """Testing the event"""
        # creating an emulambda function
        func = emulambda.import_lambda('cleanuplambda.lambda_handler')
        # creating an emulambda event
        event = emulambda.parse_event(
            open('../ndlambda/functions/cleanup/cleanup_event.json').read())
        # calling the emulambda function to invoke a lambda
        emulambda.invoke_lambda(func, event, None, 0, None)

        # test if there are any tiles leftover in tile bucket
        for z_index in range(self.z_tile, settings.SUPER_CUBOID_SIZE[2], 1):
            tile = self.tile_bucket.getObject(nd_proj.channel_name,
                                              nd_proj.resolution, self.x_tile,
                                              self.y_tile, z_index)
            assert (tile is None)

        # check if there are any entires left in the tileindex table
        supercuboid_key = self.tileindex_db.generatePrimaryKey(
            nd_proj.channel_name, nd_proj.resolution, self.x_tile, self.y_tile,
            self.z_tile)
        item = self.tileindex_db.getItem(supercuboid_key)
        assert (item is None)

        # testing if the message was deleted from the cleanup queue or not
        for message in self.cleanup_queue.receiveMessage():
            # KL TODO write the message id into the JSON event file directly
            print message
Example #2
0
 def test_invoke_lambda(self):
     try:
         def test_func(e, c):
             return "foo"
         event = {"foo": "bar"}
         context = {"baz": "qux"}
         emulambda.invoke_lambda(test_func, event, context, 300)
         assert True
     except BaseException as e:
         self.fail("Failed to invoke lambda.\n%s" % e.message)
Example #3
0
    def test_invoke_lambda(self):
        try:

            def test_func(e, c):
                return "foo"

            event = {"foo": "bar"}
            context = {"baz": "qux"}
            emulambda.invoke_lambda(test_func, event, context, 300, None)
            assert True
        except BaseException as e:
            self.fail("Failed to invoke lambda.\n%s" % e.message)
 def test_get_repos(self):
     event = {}
     with open('tests/intent-get-repos.json', 'r') as intent_file:
         event_json=intent_file.read().replace('\n', '')
         event = json.loads(event_json)
     result, exec_clock = emulambda.invoke_lambda(lambda_handler, event, None, 300, '')
     print('result = '+str(result))
     self.assertEqual(result['response']['reprompt']['outputSpeech']['text'], 'Should I list more?')
Example #5
0
    def test_Uploadevent(self):
        """Testing the event"""
        # creating an emulambda function
        func = emulambda.import_lambda("ingestlambda.lambda_handler")
        # creating an emulambda event
        event = emulambda.parse_event(
            open("../ndlambda/functions/ingest/ingest_event.json").read())
        # calling the emulambda function to invoke a lambda
        emulambda.invoke_lambda(func, event, None, 0, None)

        # testing if the supercuboid was inserted in the bucket
        morton_index = XYZMorton(self.tiles)
        cuboid = self.cuboid_bucket.getObject(nd_proj.channel_name,
                                              nd_proj.resolution, morton_index)

        # testing if the message was removed from the ingest queue
        for message in self.ingest_queue.receiveMessage():
            # KL TODO write the message id into the JSON event file directly
            print(message)
Example #6
0
    def test_Uploadevent(self):
        """Testing the event"""
        # creating an emulambda function
        func = emulambda.import_lambda("uploadlambda.lambda_handler")
        # creating an emulambda event
        event = emulambda.parse_event(
            open("../ndlambda/functions/upload/upload_event.json").read())
        # calling the emulambda function to invoke a lambda
        emulambda.invoke_lambda(func, event, None, 0, None)

        # testing if the index was updated in tileindexdb
        supercuboid_key = self.tileindex_db.generatePrimaryKey(
            nd_proj.channel_name,
            nd_proj.resolution,
            self.x_tile,
            self.y_tile,
            self.z_tile,
        )
        item = self.tileindex_db.getItem(supercuboid_key)
        assert item["zindex_list"] == set([0])

        # testing if the message was deleted from the upload queue or not
        for message in self.upload_queue.receiveMessage():
            assert False