def test_add_docs_amount_to_tender(self): self.assertEqual(self.process_tracker.tender_documents_to_process, {}) self.process_tracker.add_docs_amount_to_tender(self.tender_id, 2) self.assertEqual(self.process_tracker.tender_documents_to_process, {db_key(self.tender_id): 2}) self.process_tracker.add_docs_amount_to_tender(self.tender_id, 3) self.assertEqual(self.process_tracker.tender_documents_to_process, {db_key(self.tender_id): 5})
def test_remove_docs_amount_from_tender(self): self.assertEqual(self.process_tracker.tender_documents_to_process, {}) self.process_tracker.tender_documents_to_process = { db_key(self.tender_id): 2 } self.assertEqual(self.process_tracker.tender_documents_to_process, {db_key(self.tender_id): 2}) self.process_tracker.remove_docs_amount_from_tender(self.tender_id) self.assertEqual(self.process_tracker.tender_documents_to_process, {db_key(self.tender_id): 1}) self.process_tracker.remove_docs_amount_from_tender(self.tender_id) self.assertEqual(self.process_tracker.tender_documents_to_process, {})
def _remove_docs_amount_from_tender(self, tender_id): if self.tender_documents_to_process[tender_id] > 1: self.tender_documents_to_process[tender_id] -= 1 else: self._db.put(db_key(tender_id), datetime.now().isoformat(), self.ttl) del self.tender_documents_to_process[tender_id]
def test_set_item(self): self.assertEqual(self.process_tracker.processing_items, {}) self.assertEqual(self.process_tracker.tender_documents_to_process, {}) self.process_tracker.set_item(self.tender_id, self.item_id, 1) self.assertEqual(self.process_tracker.processing_items, {item_key(self.tender_id, self.item_id): 1}) self.assertEqual(self.process_tracker.tender_documents_to_process, {db_key(self.tender_id): 1})
def check_processed_tenders(self, tender_id): return self._db.has(db_key(tender_id)) or False