Ejemplo n.º 1
0
 def test_target(self):
     target = DateTarget('01-03-2020')
     self.assertEqual(target.target_value, datetime(year=2020, day=1, month=3))
     self.assertEqual(target.get_distance('02-03-2020'), 1)
     self.assertEqual(target.get_distance('28-02-2020'), 2)
     self.assertEqual(target.get_distance('01-03-2020'), 0)
     self.assertEqual(target.get_distance('02-04-2020'), 32)
     self.assertEqual(target.get_distance('01-03-2021'), 365)
Ejemplo n.º 2
0
    def test_two_preferences_one_low_above(self):
        target = [DateTarget('01-03-2020'), DateTarget('10-03-2020')]
        preference = DatePreference(100, target)
        self.assertEqual(
            preference.maximum_possible_distance(
                today=datetime(year=2020, month=3, day=1),
                last_day=datetime(year=2020, month=3, day=25)
            ),

            15
        )
Ejemplo n.º 3
0
    def test_single_preference_low_limit(self):
        target = [DateTarget('01-03-2020'), ]
        preference = DatePreference(100, target)
        self.assertEqual(
            preference.maximum_possible_distance(
                today=datetime(year=2020, month=3, day=1),
                last_day=datetime(year=2020, month=3, day=31)),

            30
        )
Ejemplo n.º 4
0
    def test_parser_standard(self):
        hour_preference = HourPreference(
            80,
            [
                HourTarget('06:00', '08:00'),
                HourTarget('18:00', '21:00'),
            ]
        )
        date_preference = DatePreference(
            20,
            [
                DateTarget('02-03-2020'),
                DateTarget('03-03-2020'),
            ]
        )

        parser = PreferenceParser((hour_preference, date_preference))
        self.assertEqual(parser.compile_distance({'hour': '06:00', 'date': '02-03-2020'}), 0)
        self.assertEqual(parser.compile_distance(
            {'hour': '06:00', 'date': '04-03-2020'},
            today=datetime(year=2020, day=1, month=3),
            last_day=datetime(year=2020, month=3, day=5)),
            0.1
        )
Ejemplo n.º 5
0
            self.main_window = self.driver.current_window_handle
            sleep(60)
            self.run(specialty=specialty,
                     doctor=doctor,
                     start_hour=start_hour,
                     end_hour=end_hour,
                     region=region)
            print("New connection error.")
        except:
            now = datetime.now().strftime('%d-%m-%Y %H:%M')
            self.driver.save_screenshot(f'./{now}.png')
            traceback.print_exc()
            sys.exit()


monika_prefs = PreferenceParser([
    DatePreference(weight=80, targets=[
        DateTarget('17-08-2020'),
    ]),
    HourPreference(weight=20,
                   targets=[
                       HourTarget('06:00', '10:00'),
                       HourTarget('18:00', '22:00'),
                   ],
                   required=False)
], )

med_bot = Medicover(medi_login, medi_pwd, monika_prefs)

med_bot.run(specialty="Gastroenterolog dorośli", doctor="Wylegała Zbigniew")