Exemplo n.º 1
0
 def test_complex_value_minutes(self):
     oh = OpeningHours("Mo 10:00-12:00,12:30-15:00; Tu-Fr 08:00-12:00,12:30-15:00; Sa 08:00-12:00")
     self.assertEqual(oh.minutes_to_closing("Su", "10:00"), 0)
     self.assertEqual(oh.minutes_to_closing("Mo", "10:30"), 90)
     self.assertEqual(oh.minutes_to_closing("Mo", "12:15"), 0)
     self.assertEqual(oh.minutes_to_closing("We", "14:00"), 60)
     self.assertEqual(oh.minutes_to_closing("Sa", "14:00"), 0)
Exemplo n.º 2
0
 def test_dataset(self):
     # Test with an extract of opening_hours from OSM Oxfordshire
     # Values known to be incorrect have been removed, you can see
     # the complete file (vs. _valid) in the tests/ directory.
     lines = open("tests/dataset_oxfordshire_20120829_valid").readlines()
     for line in lines:
         oh = OpeningHours(line)
         oh.is_open("Mo", "14:00")
Exemplo n.º 3
0
 def test_complex_value(self):
     oh = OpeningHours("Mo 10:00-12:00,12:30-15:00; Tu-Fr 08:00-12:00,12:30-15:00; Sa 08:00-12:00; PH 09:00-11:30;")
     self.assertEqual(oh.is_open("Su", "10:00"), False)
     self.assertEqual(oh.is_open("Mo", "10:30"), True)
     self.assertEqual(oh.is_open("Mo", "12:15"), False)
     self.assertEqual(oh.is_open("We", "14:00"), True)
     self.assertEqual(oh.is_open("Sa", "14:00"), False)
     self.assertEqual(oh.is_open("ph", "10:00"), True)
Exemplo n.º 4
0
 def test_exception(self):
     oh = OpeningHours("Mo-Fr 09:00-17:30; We 09:00-13:00; Sa 09:00-12:00")
     self.assertEqual(oh.is_open("Mo", "14:00"), True)
     self.assertEqual(oh.is_open("We", "12:00"), True)
     self.assertEqual(oh.is_open("We", "14:00"), False)
     self.assertEqual(oh.is_open("Tu", "14:00"), True)
     self.assertEqual(oh.is_open("Sa", "11:00"), True)
     self.assertEqual(oh.is_open("Sa", "14:00"), False)
     self.assertEqual(oh.is_open("Su", "10:00"), False)
Exemplo n.º 5
0
def filter_by(features, day, time):
    filtered = []
    for city in features:
        opening_hours = city["properties"].get("opening_hours")
        if opening_hours is None:
            continue
        openings = OpeningHours(opening_hours)
        if openings.is_open(day, time):
            filtered.append(city)
    return filtered
Exemplo n.º 6
0
 def test_twenty_four_seven(self):
     oh = OpeningHours("24/7")
     self.assertEqual(oh.is_open("Mo", "15:00"), True)
Exemplo n.º 7
0
 def test_day_off(self):
     oh = OpeningHours("Mo-Sa 09:30-20:45; Su off;")
     self.assertEqual(oh.is_open("Fr", "20:44"), True)
     self.assertEqual(oh.is_open("su", "12:00"), False)
Exemplo n.º 8
0
 def test_parse_multiple_days(self):
     oh = OpeningHours("Mo-Fr 08:30-20:00")
     self.assertEqual(oh.is_open("Mo", "12:00"), True)
     self.assertEqual(oh.is_open("Tu", "12:00"), True)
     self.assertEqual(oh.is_open("Fr", "12:00"), True)
     self.assertEqual(oh.is_open("Su", "12:00"), False)
Exemplo n.º 9
0
 def test_we_24(self):
     oh = OpeningHours("Sa-Su 00:00-24:00")
     self.assertEqual(oh.is_open("Sa", "13:00"), True)
     self.assertEqual(oh.is_open("Mo", "06:00"), False)
Exemplo n.º 10
0
 def test_parse_one_day(self):
     oh = OpeningHours("Mo 10:00-16:00")
     self.assertEqual(oh.is_open("Mo", "15:00"), True)
     self.assertEqual(oh.is_open("Mo", "18:00"), False)
Exemplo n.º 11
0
 def test_day_off(self):
     oh = OpeningHours("Mo-Sa 09:30-20:45; Su off;")
     self.assertEqual(oh.is_open("Fr", "20:44"), True)
     self.assertEqual(oh.is_open("su", "12:00"), False)
Exemplo n.º 12
0
 def test_parse_multiple_days(self):
     oh = OpeningHours("Mo-Fr 08:30-20:00")
     self.assertEqual(oh.is_open("Mo", "12:00"), True)
     self.assertEqual(oh.is_open("Tu", "12:00"), True)
     self.assertEqual(oh.is_open("Fr", "12:00"), True)
     self.assertEqual(oh.is_open("Su", "12:00"), False)
Exemplo n.º 13
0
 def test_we_24(self):
     oh = OpeningHours("Sa-Su 00:00-24:00")
     self.assertEqual(oh.is_open("Sa", "13:00"), True)
     self.assertEqual(oh.is_open("Mo", "06:00"), False)
Exemplo n.º 14
0
 def test_parse_one_day(self):
     oh = OpeningHours("Mo 10:00-16:00")
     self.assertEqual(oh.is_open("Mo", "15:00"), True)
     self.assertEqual(oh.is_open("Mo", "18:00"), False)