Ejemplo n.º 1
0
def test_center_to_centerdict():
    center = CenterInfo(
        "28", "Delphine ROUSSEAU",
        "https://patient.avecmondoc.com/fiche/structure/delphine-rousseau-159")
    center.metadata = {
        "address": "21 Rue Nicole 28000 Chartres",
        "phone_number": "0033143987678",
        "business_hours": {
            "Lundi": "08:30-12:30 13:30-17:00",
            "Mardi": "08:30-12:30 13:30-17:00",
            "Mercredi": "08:30-12:30 13:30-17:00",
            "Jeudi": "08:30-12:30 13:30-17:00",
            "Vendredi": "08:30-12:30 13:30-17:00",
            "Samedi": "",
            "Dimanche": "",
        },
    }
    center.location = CenterLocation(1.481373, 48.447586, "Chartres", "28000")
    center.internal_id = "amd159"
    center.type = DRUG_STORE

    data_file = Path("tests/fixtures/avecmondoc/centerdict.json")
    data = json.loads(data_file.read_text(encoding="utf8"))

    assert center_to_centerdict(center) == data
Ejemplo n.º 2
0
def organization_to_center(organization) -> Optional[CenterInfo]:
    if organization is None:
        return None
    url = AVECMONDOC_CONF.get("patient_url", "").format(slug=organization.get("slug"))
    id = organization["id"]
    zip = organization["zipCode"]
    dept = departementUtils.to_departement_number(departementUtils.cp_to_insee(zip))
    reasons = organization["consultationReasons"]
    if reasons is None:
        logger.warning(f"no reasons found in organization")
        return None
    if get_valid_reasons(reasons) == []:
        return None
    center = CenterInfo(dept, organization["name"], url)
    location = CenterLocation(0, 0, organization["city"], organization["zipCode"])
    if organization.get("coordinates") is not None:
        location.longitude = organization["coordinates"].get("lng", 0.0)
        location.latitude = organization["coordinates"].get("lat", 0.0)
    center.metadata = {
        "address": organization["address"],
        "phone_number": organization["phone"],
    }
    center.location = location
    center.internal_id = f"amd{id}"
    if "schedules" not in organization:
        return center
    business_hours = {}
    for day, day_name in AVECMONDOC_SCRAPER.get("business_days", {}).items():
        value = ""
        if organization["schedules"][day]["enabled"]:
            value = " ".join(f'{sc["start"]}-{sc["end"]}' for sc in organization["schedules"][day]["schedules"])
        business_hours[day_name] = value
    center.metadata["business_hours"] = business_hours
    return center
Ejemplo n.º 3
0
def test_organization_to_center():
    data_file = Path("tests/fixtures/avecmondoc/get_organization_slug.json")
    data = json.loads(data_file.read_text(encoding='utf8'))
    center = CenterInfo(
        "28", 
        "Delphine ROUSSEAU", 
        "https://patient.avecmondoc.com/fiche/structure/delphine-rousseau-159"
    )
    center.metadata = {
        "address": "21 Rue Nicole 28000 Chartres",
        "phone_number": "0033143987678",
        "business_hours": {
            "Lundi": "08:30-12:30 13:30-17:00",
            "Mardi": "08:30-12:30 13:30-17:00",
            "Mercredi": "08:30-12:30 13:30-17:00",
            "Jeudi": "08:30-12:30 13:30-17:00",
            "Vendredi": "08:30-12:30 13:30-17:00",
            "Samedi": "",
            "Dimanche": "",
            }
    }
    center.location = CenterLocation(1.481373, 48.447586, "Chartres", "28000")
    center.internal_id = "amd159"
    assert avecmondoc.organization_to_center(data).default() == center.default()