def test_argument_chain(self): func = MagicMock(side_effect=[0, 1]) slf = mock_spotify() dec = chunked('a', 1, 10, return_last, chain='ch', chain_pos=2)(func) r = dec(slf, list(range(20)), ch=None) func.assert_called_with(slf, list(range(10, 20)), ch=0) self.assertEqual(r, 1)
def test_dont_reverse_when_rev_argument_not_specified(self): func = MagicMock(side_effect=[0, 1]) slf = mock_spotify() dec = chunked('a', 1, 10, return_last, reverse='rev', reverse_pos=2)(func) r = dec(slf, list(range(20))) func.assert_called_with(slf, list(range(10, 20))) self.assertEqual(r, 1)
def test_chunked_as_kwarg(self): func = MagicMock(side_effect=[0, 1]) dec = chunked('a', 2, 10, return_last)(func) r = dec(mock_spotify(), 0, a=list(range(20))) self.assertEqual(r, 1)
def test_chunked_return_none(self): func = MagicMock() dec = chunked('a', 1, 10, return_none)(func) r = dec(mock_spotify(), list(range(20))) self.assertIsNone(r)