예제 #1
0
def test_process_data():
    def fff():
        print("fff")

    _handle, benchmark_file = tempfile.mkstemp()
    try:
        for _i in range(55):
            lexnlp_tests.benchmark(lexnlp_tests.build_extraction_func_name(fff), fff, benchmark_file=benchmark_file)
        res = []

        def process(actions: List[Dict]):
            res.extend(actions)

        upload_benchmarks.process_data(benchmark_file, 'index2', process)

        d1 = res[0]
        assert_equals('fff(text)', d1['_source']['function'])
    finally:
        if benchmark_file:
            os.remove(benchmark_file)
예제 #2
0
    def test_process_data(self):
        def fff():
            print("fff")

        _handle, benchmark_file = tempfile.mkstemp()
        try:
            for _i in range(55):
                lexnlp_tests.benchmark(
                    lexnlp_tests.build_extraction_func_name(fff),
                    fff,
                    benchmark_file=benchmark_file)
            res = []

            # pylint: disable=unnecessary-lambda
            upload_benchmarks.process_data(benchmark_file, 'index2',
                                           lambda actions: res.extend(actions))

            d1 = res[0]
            self.assertEqual('fff(text)', d1['_source']['function'])
        finally:
            if benchmark_file:
                os.remove(benchmark_file)