def test_flush_method(self): validator = Validator(None) validator.enqueue = Mock() validator.flush() expect(validator.enqueue.call_count).to_equal(0) validator = Validator(None) validator.url_buffer = [1, 2, 3] validator.enqueue = Mock() validator.flush() validator.enqueue.assert_called_once_with([1, 2, 3])
def test_flush_method(self): validator = Validator(None) validator.enqueue = Mock() validator.flush() expect(validator.enqueue.call_count).to_equal(0) validator = Validator(None) validator.url_buffer = [1, 2, 3] validator.enqueue = Mock() validator.flush() validator.enqueue.assert_called_once_with([1, 2, 3])
def test_send_url(self): validator = Validator(Mock(config=Mock(MAX_ENQUEUE_BUFFER_LENGTH=1))) validator.flush = Mock() validator.test_url = Mock(return_value=True) expect(len(validator.url_buffer)).to_equal(0) validator.send_url("the-url", 0.0, "the-response") expect(len(validator.url_buffer)).to_equal(1) expect(validator.flush.call_count).to_equal(0) validator.send_url("the-url-2", 0.0, "the-response-2") expect(len(validator.url_buffer)).to_equal(2) expect(validator.flush.call_count).to_equal(1)
def test_send_url(self): validator = Validator(Mock(config=Mock(MAX_ENQUEUE_BUFFER_LENGTH=1))) validator.flush = Mock() validator.test_url = Mock(return_value=True) expect(len(validator.url_buffer)).to_equal(0) validator.send_url('the-url', 0.0, 'the-response') expect(len(validator.url_buffer)).to_equal(1) expect(validator.flush.call_count).to_equal(0) validator.send_url('the-url-2', 0.0, 'the-response-2') expect(len(validator.url_buffer)).to_equal(2) expect(validator.flush.call_count).to_equal(1)