def test_processing_with_date_as_string_after(self): processing = ProcessingFactory.build() with patch.object(Repository, 'has_processing_after', return_value=True) as has_processing_after_request, \ patch.object(Repository, 'first_processing_after', return_value=processing) as first_processing_after_request: self.subject.processing_with_date(self.date_str) has_processing_after_request.assert_called_once_with(self.date) first_processing_after_request.assert_called_once_with(self.date)
def test_processing_without_ready_processing(self): processing = ProcessingFactory.build() with patch.object(Repository, 'has_ready_processing', return_value=False) as has_ready_processing_request, \ patch.object(Repository, 'last_processing', return_value=processing) as last_processing_request: self.subject.processing() has_ready_processing_request.assert_called_once() last_processing_request.assert_called_once()
def test_last_ready_processing(self): processing = ProcessingFactory.build() processing_hash = {'last_ready_processing': processing._asdict()} with patch.object(Repository, 'request', return_value=processing_hash) as repository_request: response = self.subject.last_ready_processing() repository_request.assert_called_once_with(':id/last_ready_processing', params={'id': self.subject.id}, method='get') assert_equal(response, processing)
def test_last_processing_before(self): processing = ProcessingFactory.build() processing_hash = {'processing': processing._asdict()} with patch.object(Repository, 'request', return_value=processing_hash) as repository_request: response = self.subject.last_processing_before(self.date) repository_request.assert_called_once_with(':id/last_processing/before', params={'id': self.subject.id, 'date': self.date_str}) assert_equal(response, processing)
def test_processing_with_date_before(self): processing = ProcessingFactory.build() with patch.object(Repository, 'has_processing_after', return_value=False) as has_processing_after_request, \ patch.object(Repository, 'has_processing_before', return_value=True) as has_processing_before_request, \ patch.object(Repository, 'last_processing_before', return_value=processing) as last_processing_before_request: self.subject.processing_with_date(self.date) has_processing_after_request.assert_called_once_with(self.date) has_processing_before_request.assert_called_once_with(self.date) last_processing_before_request.assert_called_once_with(self.date)
def test_processing(self): processing = ProcessingFactory.build() with patch.object(Processing, 'find', return_value=processing) as find_request: first_processing = self.subject.processing second_processing = self.subject.processing assert_equal(first_processing, processing) assert_equal(first_processing, second_processing) find_request.assert_called_once_with(self.subject.processing_id)
def setUp(self): self.subject = ProcessingFactory.build() self.process_time = ProcessTimeFactory.build() self.process_times = [self.process_time]