def test_abstract_workload_getitem(): arg = 1 gotten_item = 5 mock_workload = mock.MagicMock(spec=AbstractWorkload) mock_workload.get.return_value = gotten_item ret_val = AbstractWorkload.__getitem__(mock_workload, arg) assert ret_val == 5 mock_workload.get.assert_called_once_with(arg)
def test_abstract_workload_getitem_fail(): mock_workload = mock.MagicMock(spec=AbstractWorkload) mock_workload.get.return_value = None with pytest.raises(KeyError): _ = AbstractWorkload.__getitem__(mock_workload, 1)