def test_basic_event_status(status_type, status_number): event_status = posting.EventStatus(status_type, status_number) assert event_status.type == status_type assert event_status.status == status_number assert event_status.display_event_type == TRACKING_EVENT_TYPES[status_type] assert str(event_status) == "({}, {})".format(status_type, status_number) assert repr(event_status) == "<EventStatus({!r}, {!r})>".format( status_type, status_number)
def test_invalid_event_status(event_type): with pytest.raises(exceptions.InvalidEventStatusError): posting.EventStatus(event_type, 1)
def test_event_status(): event_status = posting.EventStatus("BDE", 1) assert repr(event_status) == "<EventStatus('BDE', 1)>"
result = (per_unit_value - insurance_value_threshold) * INSURANCE_PERCENTUAL_COST * quantity value = posting.Package.calculate_insurance(per_unit_value=per_unit_value, quantity=quantity, service=service) assert value == to_decimal(result) def test_event_status(): event_status = posting.EventStatus("BDE", 1) assert repr(event_status) == "<EventStatus('BDE', 1)>" @pytest.mark.parametrize("status", (posting.EventStatus("BDE", "01"), ("BDE", "01"))) def test_basic_tracking_event(status): tracking_event = posting.TrackingEvent( timestamp=datetime(2010, 1, 2, 1, 2), status=status, location_zip_code="82940150", location="Correios", receiver="José", city="Curitiba", state="PR", document="XYZ", comment="The comment", description="The description", details="The details", )
def test_calculate_insurance_sedex(): value = posting.Package.calculate_insurance(per_unit_value=Decimal(500), service=SERVICE_SEDEX) assert value == Decimal('2.98') value = posting.Package.calculate_insurance(per_unit_value=Decimal(500), quantity=2, service=SERVICE_SEDEX) assert value == Decimal('5.95') def test_event_status(): event_status = posting.EventStatus('BDE', 1) assert repr(event_status) == "<EventStatus('BDE', 1)>" @pytest.mark.parametrize("status", (posting.EventStatus("BDE", "01"), ("BDE", "01"))) def test_basic_tracking_event(status): tracking_event = posting.TrackingEvent( timestamp=datetime(2010, 1, 2, 1, 2), status=status, location_zip_code="82940150", location="Correios", receiver="José", city="Curitiba", state="PR", document="XYZ", comment="The comment", description="The description", details="The details", )