コード例 #1
0
    def test_case_1(self, prototypical_showtimes):
        theatre = Theatre(name=prototypical_showtimes[0]['name'], showtimes=prototypical_showtimes[0]['showtimes'])
        theatre.calculate_double_dips(max_waiting_time=0, max_overlap_time=0)

        expected_dips = [DoubleDip(theatre.showtimes[0]), DoubleDip(theatre.showtimes[1])]

        assert theatre.double_dips == expected_dips
コード例 #2
0
def cinestar_berlin(self):
    cinestar_berlin = json.load(open('dairy_queen/tests/cinestar_berlin.json'))
    theatre = Theatre(name=cinestar_berlin['name'], showtimes=cinestar_berlin['showtimes'])

    # test the situation where all films should be singleton dips:
    # setting max_waiting_time=0 & max_overlap_time=-5 is an impossible condition
    theatre.calculate_double_dips(max_waiting_time=0, max_overlap_time=-5)
    expected_dips = [
        DoubleDip(movie) for movie in theatre.showtimes
        ]
    assert theatre.double_dips == expected_dips

    # test the situation where only films that are perfectly back-to-back are
    # double dips
    theatre.calculate_double_dips(max_waiting_time=0, max_overlap_time=0)
    non_trivial_dips = []
    for double_dip in theatre.double_dips:
        if len(double_dip) > 1:
            non_trivial_dips.append(double_dip)
    expected_dips = []

    assert non_trivial_dips == expected_dips
コード例 #3
0
def create_theatre_and_calc_double_dips(theatre_json, max_waiting_mins=20, max_overlap_mins=6):
    theatre = Theatre(name=theatre_json['name'], showtimes=theatre_json['showtimes'])
    theatre.calculate_double_dips(max_waiting_mins, max_overlap_mins)
    theatre.showtimes.sort(key=attrgetter('name'))
    return theatre