Example #1
0
def test_task_check(ts):
    api = MyAPI()
    api._check('asdf')

    print(ts.mock_calls)
    assert ts.call_count == 1
    ts.return_value.check_task.assert_called_once_with('asdf')
Example #2
0
def test_index_page():
    api = MyAPI()
    api._start = mock.Mock()
    api._check = mock.Mock()

    api.index()
    api._start.assert_called_once_with()

    api.index('asdf')
    api._check.assert_called_once_with('asdf')
Example #3
0
def test_task_creation(ts):
    api = MyAPI()
    api._start()

    assert ts.call_count == 1
    assert ts.return_value.post_task.call_count == 1
    first_args = ts.return_value.post_task.call_args

    ts.reset_mock()
    api._start()
    assert ts.call_count == 1
    assert ts.return_value.post_task.call_count == 1
    second_args = ts.return_value.post_task.call_args

    assert first_args != second_args
Example #4
0
def test_cancel_page(ts):
    api = MyAPI()
    api.cancel('asdf')

    assert ts.call_count == 1
    ts.return_value.cancel_task.assert_called_once_with('asdf')