def test_getDisplayValueFromAttribute_NoStatusAndOnlyArrivalisLessThanOrEqualTo30Sec_ReturnArriving( ): now = datetime.datetime.now() now = now.replace(tzinfo=constants.UTC_ZONE) now = now.astimezone(constants.EST_ZONE) nowPlus30Sec = now + datetime.timedelta(0, 30) nowPlus30SecIsoFormat = nowPlus30Sec.isoformat() attribute = {"status": None, "arrival_time": nowPlus30SecIsoFormat} assert sendToClient.getDisplayValueFromAttribute(attribute) == "Arriving"
def test_getDisplayValueFromAttribute_StatusIsSTOPPED_ATAndArrivalIsGreaterThan90Sec_ReturnStoppedAt( ): now = datetime.datetime.now() now = now.replace(tzinfo=constants.UTC_ZONE) now = now.astimezone(constants.EST_ZONE) nowPlus91Sec = now + datetime.timedelta(0, 91) nowPlus91SecIsoFormat = nowPlus91Sec.isoformat() attribute = {"status": "STOPPED_AT", "arrival_time": nowPlus91SecIsoFormat} assert sendToClient.getDisplayValueFromAttribute(attribute) == "STOPPED_AT"
def test_getDisplayValueFromAttribute_NoStatusAndOnlyDepartureIsAvailable_ReturnDeparture( ): now = datetime.datetime.now() now = now.replace(tzinfo=constants.UTC_ZONE) now = now.astimezone(constants.EST_ZONE) nowPlus120Sec = now + datetime.timedelta(0, 120) nowPlus120SecIsoFormat = nowPlus120Sec.isoformat() attribute = {"status": None, "departure_time": nowPlus120SecIsoFormat} assert sendToClient.getDisplayValueFromAttribute(attribute) == "2 minutes"
def test_getDisplayValueFromAttribute_HasStatus_ReturnStatus(): attribute = {"status": "STATUS"} assert sendToClient.getDisplayValueFromAttribute( attribute) == attribute["status"]
def test_getDisplayValueFromAttribute_NullObect_ReturnNull(): assert sendToClient.getDisplayValueFromAttribute(None) == ""