async def test_single_file_bid_default(mock_client): # arrange engine = Microengine(mock_client, bid_strategy=DefaultStrategy()) # act bid = await engine.bid('test', [True], [True], [1.0], [''], 'side') # assert assert bid == [1 * 10**18]
async def test_artifact_0_conf_255_1_conf(): # arrange bid_strategy = DefaultStrategy() # act bid = await bid_strategy.bid('test', [True] * 256, [True] * 256, [0.0] + [1.0] * 255, [''], .0625 * 10 ** 18, 1 * 10 ** 18, 'side') # assert assert bid == [.0625 * 10 ** 18] + [1 * 10 ** 18] * 255
async def test_default_bid_strategy_directly(): # arrange bid_strategy = DefaultStrategy() # act bid = await bid_strategy.bid('test', [True], [True], [1.0], [''], .0625 * 10 ** 18, 1 * 10 ** 18, 'side') # assert assert bid == [1 * 10 ** 18]
async def test_mask_0_bid_value_0(): # arrange bid_strategy = DefaultStrategy() # act bid = await bid_strategy.bid('test', [False], [True], [1.0], [''], .0625 * 10 ** 18, 1 * 10 ** 18, 'side') # assert assert bid == []
async def test_two_files_mixed_50_confidence(mock_client): # arrange engine = Microengine(mock_client, bid_strategy=DefaultStrategy()) # act bid = await engine.bid('test', [True, True], [True, True], [.75, .25], ['', ''], 'side') # assert assert bid == [0.765625 * 10 ** 18, 0.296875 * 10 ** 18]
async def test_two_files_one_mask_75_confidence(mock_client): # arrange engine = Microengine(mock_client, bid_strategy=DefaultStrategy()) # act bid = await engine.bid('test', [True, False], [True, True], [.75, .2], ['', ''], 'side') # assert assert bid == [0.765625 * 10 ** 18]
async def test_two_files_0_confidence(mock_client): # arrange engine = Microengine(mock_client, bid_strategy=DefaultStrategy()) # act bid = await engine.bid('test', [True, True], [True, True], [0, 0], ['', ''], 'side') # assert assert bid == [.0625 * 10 ** 18] * 2
async def test_test_file_bid_mast_false_default(mock_client): # arrange engine = Microengine(mock_client, bid_strategy=DefaultStrategy()) # act bid = await engine.bid('test', [False], [True], [1.0], [''], 'side') # assert assert bid == .0625 * 10**18
async def test_256_files_mixed_75_confidence(mock_client): # arrange engine = Microengine(mock_client, bid_strategy=DefaultStrategy()) confidences = ([1.0] * 128) confidences.extend([.5] * 128) # act bid = await engine.bid('test', [True] * 256, [True] * 256, confidences, [''] * 256, 'side') # assert assert bid == [1 * 10 ** 18] * 128 + [.53125 * 10 ** 18] * 128
async def test_stop_calls_scanner_teardown(mock_client): teardown = asyncio.Event() class Scanner(AbstractScanner): async def teardown(self): teardown.set() Microengine(mock_client, scanner=Scanner(), bid_strategy=DefaultStrategy()) await mock_client.on_stop.run() await teardown.wait()