예제 #1
0
def test_microsecond_truncation():
    """Microseconds should be rounded in FHIR output"""
    sample = datetime.utcnow()
    sample = sample.replace(tzinfo=pytz.utc)

    if sample.microsecond == 0:
        sample = sample.replace(microsecond=1234567890)
    assert sample.isoformat() != FHIR_datetime.as_fhir(sample)

    expected = sample.replace(microsecond=0)
    assert expected.isoformat() == FHIR_datetime.as_fhir(sample)
예제 #2
0
def test_tz_aware_output():
    """FHIR_datetime.as_fhir() should always be tz aware (UTC)"""
    unaware = datetime(2016, 7, 15, 9, 20, 37, 0)

    # generate fhir - expect UTC tz info at end
    isostring = FHIR_datetime.as_fhir(unaware)
    assert isostring[-6:] == '+00:00'