Skip to content

Commit

Permalink
Add option to add additional center or doctor
Browse files Browse the repository at this point in the history
  • Loading branch information
danburg committed Jul 8, 2021
1 parent 7bd2004 commit b684ab4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Further optional arguments:
exclude centers
--center-exclude-regex CENTER_EXCLUDE_REGEX
exclude centers by regex
--additional-center "name;city;link", -ac "name;city;link"
Add additional centers or doctors e.g. "Corona Impfzentren - Berlin;Berlin;/institut/berlin/ciz-berlin-berlin"
--include-neighbor-city, -n
include neighboring cities
--start-date START_DATE
Expand Down
17 changes: 15 additions & 2 deletions doctoshotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def do_login(self, code):

return True

def find_centers(self, where, motives=None, page=1):
def find_centers(self, where, motives=None, page=1, additional_centers=None):
if motives is None:
motives = self.vaccine_motives.keys()
for city in where:
Expand Down Expand Up @@ -335,6 +335,17 @@ def find_centers(self, where, motives=None, page=1):
for center in self.find_centers(where, motives, next_page):
yield center

if additional_centers:
for additional_center in additional_centers:
splitted = additional_center.split(';')
if len(splitted) == 3:
yield {
"name_with_title": splitted[0], #"Corona Impfzentren - Berlin",
"city": splitted[1], #"Berlin",
"url": splitted[2], #"/institut/berlin/ciz-berlin-berlin"
}


def get_patients(self):
self.master_patient.go()

Expand Down Expand Up @@ -653,6 +664,8 @@ def main(self, cli_args=None):
action='append', help='exclude centers')
parser.add_argument('--center-exclude-regex',
action='append', help='exclude centers by regex')
parser.add_argument('--additional-center', '-ac',
action='append', help='Add additional centers or doctors: "name;city;link" e.g. "Corona Impfzentren - Berlin;Berlin;/institut/berlin/ciz-berlin-berlin"')
parser.add_argument(
'--include-neighbor-city', '-n', action='store_true', help='include neighboring cities')
parser.add_argument('--start-date', type=str, default=None,
Expand Down Expand Up @@ -791,7 +804,7 @@ def main(self, cli_args=None):
while True:
log_ts()
try:
for center in docto.find_centers(cities, motives):
for center in docto.find_centers(cities, motives, args.additional_center):
if args.center:
if center['name_with_title'] not in args.center:
logging.debug("Skipping center '%s'" %
Expand Down
32 changes: 32 additions & 0 deletions test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,38 @@ def test_find_centers_de_returns_502_should_fail(tmp_path):
pass


@responses.activate
def test_find_centers_de_should_return_additional_centers(tmp_path):
docto = DoctolibDE("[email protected]",
"1234", responses_dirname=tmp_path)
docto.BASEURL = "https://127.0.0.1"

responses.add(
responses.GET,
"https://127.0.0.1/impfung-covid-19-corona/K%C3%B6ln?ref_visit_motive_ids%5B%5D=6768&ref_visit_motive_ids%5B%5D=6769&ref_visit_motive_ids%5B%5D=6936&ref_visit_motive_ids%5B%5D=6937&ref_visit_motive_ids%5B%5D=7978&ref_visit_motive_ids%5B%5D=7109&ref_visit_motive_ids%5B%5D=7110&page=1",
status=200,
body="{}"
)

additional_centers = [
'Corona Impfzentren - Köln;Köln;/institut/koeln/ciz-koeln-koeln',
'Dr. Dre;Köln;/allgemeinmedizin/koeln/dr-dre'
]

centers = 0
for result in docto.find_centers(["Köln"], None, 1, additional_centers):
splitted = additional_centers[centers].split(';')

assert result['name_with_title'] == splitted[0]
assert result['city'] == splitted[1]
assert result['url'] == splitted[2]

centers += 1

assert centers == len(additional_centers)
assert len(responses.calls) == 1


@responses.activate
def test_get_next_page_fr_should_return_2_on_page_1(tmp_path):
"""
Expand Down

0 comments on commit b684ab4

Please sign in to comment.