Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to add specific center or doctor #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
Dreiundzwanzig marked this conversation as resolved.
Show resolved Hide resolved


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',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until now, we only had single-letter abbreviations for arguments but it looks like we are running out of usable letters. Still it should be a deliberate decision to extend to two-letter abbreviations. @rbignon what do you think?

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