def test_return_true_when_remarks_is_only_value_in_received_and_has_changed( self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = {'remarks': 'another remark!'} self.assertTrue( consignee.has_only_changed_editable_fields(received_consignee))
def test_return_appropriately_when_non_core_fields_exist_in_recieve(self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = { 'remarks': 'another remark!', 'randome_value': 'Whoa!' } self.assertTrue( consignee.has_only_changed_editable_fields(received_consignee))
def test_return_false_if_name_has_changed_along_with_remarks(self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = { 'name': 'Another Name', 'location': 'Some Location', 'remarks': 'another remark!' } self.assertFalse( consignee.has_only_changed_editable_fields(received_consignee))
def setUp(self): self.downloaded_consignee = downloaded_consignee self.expected_consignee = Consignee(customer_id='L438001120', name='PATHFINDER INTERNATIONAL', imported_from_vision=True) self.synchronizer = ConsigneeSynchronizer()
def __find_line_item_run_for(phone): consignees = Consignee.get_consignees_with_phone(phone) for consignee in consignees: nodes = Node.objects.filter(consignee=consignee) line_item = LineItem.objects.all() return {} return None
def setUp(self): self.downloaded_consignee = '[{"COUNTRY_CODE":"438",' \ '"COUNTRY_NAME":"Uganda",' \ '"CONSIGNEE_CODE":"L438001120",' \ '"CONSIGNEE_NAME":"PATHFINDER INTERNATIONAL"},' \ '{"COUNTRY_CODE":"438",' \ '"COUNTRY_NAME":"Uganda",' \ '"CONSIGNEE_CODE":"L438001121",' \ '"CONSIGNEE_NAME":"JACOB LONY ALERO HC III"}]' self.expected_consignee_1 = Consignee(customer_id='L438001120', name='PATHFINDER INTERNATIONAL', imported_from_vision=True) self.expected_consignee_2 = Consignee(customer_id='L438001121', name='JACOB LONY ALERO HC III', imported_from_vision=True) self.synchronizer = ConsigneeSynchronizer()
def assert_consignees_were_created(self): oyam = 'OYAM DISTRICT ADMIN' oyamID = 'L438000393' gulu = 'GULU HOSPITAL' guluID = 'L438000181' Consignee(name=oyam, customer_id=oyamID, type=Consignee.TYPES.implementing_partner, imported_from_vision=True) Consignee(name=gulu, customer_id=guluID, type=Consignee.TYPES.implementing_partner, imported_from_vision=True) consignees = Consignee.objects.all() consignee_names = [consignee.name for consignee in consignees] consignee_ids = [consignee.customer_id for consignee in consignees] self.assertEqual(len(consignees), 2) self.assertIn(oyam, consignee_names) self.assertIn(gulu, consignee_names) self.assertIn(oyamID, consignee_ids) self.assertIn(guluID, consignee_ids)
def test_return_appropriately_when_non_core_fields_exist_in_recieve(self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = {'remarks': 'another remark!', 'randome_value': 'Whoa!'} self.assertTrue(consignee.has_only_dirty_remarks(received_consignee))
def test_return_true_when_remarks_is_only_value_in_received_and_has_changed(self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = {'remarks': 'another remark!'} self.assertTrue(consignee.has_only_dirty_remarks(received_consignee))
def test_return_false_if_name_has_changed_along_with_remarks(self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = {'name': 'Another Name', 'location': 'Some Location','remarks': 'another remark!'} self.assertFalse(consignee.has_only_dirty_remarks(received_consignee))
def test_string_representation_of_consignee_is_consignee_name(self): test_consignee = 'Test Consignee' consignee = Consignee(name=test_consignee) self.assertEqual(test_consignee, str(consignee))
def test_should_have_all_expected_fields(self): fields_in_consignee = Consignee()._meta._name_map for field in ['name', 'contact_person_id']: self.assertIn(field, fields_in_consignee)
def setUp(self): self.downloaded_release_orders = [{"RELEASE_ORDER_NUMBER": u"0054155912", "RELEASE_ORDER_ITEM": 10, "RELEASE_ORDER_TYPE": "ZLO", "SALES_UNIT": "EA", "PLANT": "5631", "SHIP_TO_PARTY": "L626010384", "WAREHOUSE_NUMBER": "492", "CONSIGNEE": "L626010384", "DOCUMENT_DATE": u"/Date(1447390800000)/", "GOODS_ISSUE_DATE": u"/Date(1448254800000)/", "MATERIAL_NUMBER": "S0141021", "DELIVERY_QUANTITY": 55, "VALUE": 15030.86, "MOVING_AVG_PRICE": 273.29, "SO_NUMBER": u"0020173918", "PO_NUMBER": u"0045143984", "PO_ITEM": 10, "WBS_ELEMENT": "6260\/A0\/05\/401\/005\/001", "WAYBILL_NUMBER": u"0072124798", "FORWARDER_NO": None, "SHIPMENT_END_DATE": u"/Date(1448254800000)/", "ACTUAL_SHIPMENT_START_DATE": None, "SHIPMENT_COMPLETION_DATE": None, "RELEASE_ORDER_CREATE_DATE": u"/Date(1447390800000)/", "RELEASE_ORDER_UPDATE_DATE": u"/Date(1447390800000)/"}] self.converted_release_orders = [{"RELEASE_ORDER_NUMBER": 54155912, "RELEASE_ORDER_ITEM": 10, "RELEASE_ORDER_TYPE": "ZLO", "SALES_UNIT": "EA", "PLANT": "5631", "SHIP_TO_PARTY": "L626010384", "WAREHOUSE_NUMBER": "492", "CONSIGNEE": "L626010384", "DOCUMENT_DATE": datetime.datetime(2015, 11, 13, 8, 0), "GOODS_ISSUE_DATE": datetime.datetime(2015, 11, 23, 8, 0), "MATERIAL_NUMBER": "S0141021", "DELIVERY_QUANTITY": 55, "VALUE": 15030.86, "MOVING_AVG_PRICE": 273.29, "SO_NUMBER": 20173918, "PO_NUMBER": 45143984, "PO_ITEM": 10, "WBS_ELEMENT": "6260\/A0\/05\/401\/005\/001", "WAYBILL_NUMBER": 72124798, "FORWARDER_NO": None, "SHIPMENT_END_DATE": datetime.datetime(2015, 11, 23, 8, 0), "ACTUAL_SHIPMENT_START_DATE": None, "SHIPMENT_COMPLETION_DATE": None, "RELEASE_ORDER_CREATE_DATE": datetime.datetime(2015, 11, 13, 8, 0), "RELEASE_ORDER_UPDATE_DATE": datetime.datetime(2015, 11, 13, 8, 0)}] self._prepare_sales_and_purchase_order() consignee_1 = Consignee(customer_id='L626010384') self.expected_release_order_1 = ReleaseOrder(order_number=54155912, waybill=72124798, delivery_date=datetime.date(2015, 11, 23), consignee=consignee_1, sales_order=self.sales_order_1, purchase_order=self.purchase_order_1) item = Item(material_code='S0141021') self.expected_release_order_item_1 = ReleaseOrderItem(release_order=self.expected_release_order_1, purchase_order_item=self.purchase_order_item_1, item=item, item_number=10, quantity=55, value=Decimal('15030.86')) self.release_order_which_can_not_refer_to_sales_order \ = [{'PO_ITEM': 10, 'MATERIAL_NUMBER': 'S0141021', 'RELEASE_ORDER_ITEM': 10, 'VALUE': 15030.86, 'DELIVERY_QUANTITY': 55, 'PO_NUMBER': 45143984, 'SHIPMENT_END_DATE': '/Date(1448254800000)/', 'WAYBILL_NUMBER': 72124798, 'CONSIGNEE': 'L626010384', 'SO_NUMBER': 20170001, 'RELEASE_ORDER_NUMBER': 54155912, 'RELEASE_ORDER_UPDATE_DATE': datetime.datetime(2015, 11, 13, 8, 0)}] self.release_order_which_can_not_refer_to_purchase_order \ = [{'PO_ITEM': 10, 'MATERIAL_NUMBER': 'S0141021', 'RELEASE_ORDER_ITEM': 10, 'VALUE': 15030.86, 'DELIVERY_QUANTITY': 55, 'PO_NUMBER': 45140001, 'SHIPMENT_END_DATE': '/Date(1448254800000)/', 'WAYBILL_NUMBER': 72124798, 'CONSIGNEE': 'L626010384', 'SO_NUMBER': 20173918, 'RELEASE_ORDER_NUMBER': 54155912, 'RELEASE_ORDER_UPDATE_DATE': datetime.datetime(2015, 11, 13, 8, 0)}] start_date = '01122015' end_date = datetime.date.today().strftime('%d%m%Y') self.synchronizer = ReleaseOrderSynchronizer(start_date=start_date) base_url = 'https://devapis.unicef.org/BIService/BIWebService.svc/GetReleaseOrderInfo_JSON/' self.expected_url = base_url + start_date + '/' + end_date
def test_return_true_when_remarks_is_the_only_change(self): consignee = Consignee(name='Some Name', location='Some Location', remarks='some remark!') received_consignee = {'name': 'Some Name', 'location': 'Some Location', 'remarks': 'another remark!'} self.assertTrue(consignee.has_only_changed_editable_fields(received_consignee))