Ejemplo n.º 1
0
def test_single_event():
    """No events, but the resulting list should still have an entry for each date"""
    from_date = date(2014, 8, 1)
    to_date = from_date
    events =  [
        (date(2014,  8,  1),1,"DISPATCH"),
    ]
    result = do_report(from_date, to_date, events)
    assert result, [{"DISPATCH":1}]
Ejemplo n.º 2
0
def test_multi_events_one_day():
    """Still on one day so we don't have to aggregate days, but multiple events."""
    from_date = date(2014, 8, 1)
    to_date = from_date
    events =  [
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"WITH_CUSTOMER"),
    ]
    result = do_report(from_date, to_date, events)
    assert result, [{"DISPATCH":2, "WITH_CUSTOMER":1}]
Ejemplo n.º 3
0
def test_multi_events_two_days():
    """Aggregate results from previous day"""
    from_date = date(2014, 8, 1)
    to_date = from_date + timedelta(1)
    events =  [
        (date(2014,  8,  2),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"WITH_CUSTOMER"),
        (date(2014,  8,  2),1,"WITH_CUSTOMER"),
    ]
    result = do_report(from_date, to_date, events)
    assert result, [
                    {"DISPATCH":2, "WITH_CUSTOMER":1},
                    {"DISPATCH":1, "WITH_CUSTOMER":2},
                    ]
Ejemplo n.º 4
0
def test_data_out_of_range():
    """Include data before start, ignore data after end"""
    from_date = date(2014, 8, 1)
    to_date = from_date + timedelta(1)
    events =  [
        (date(2014,  8,  2),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  7,  31),1,"DISPATCH"),
        (date(2014,  8,  3),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"WITH_CUSTOMER"),
        (date(2014,  8,  2),1,"WITH_CUSTOMER"),
    ]
    result = do_report(from_date, to_date, events)
    assert result == [
                        {"DISPATCH":2, "WITH_CUSTOMER":1},
                        {"DISPATCH":1, "WITH_CUSTOMER":2},
                    ]
Ejemplo n.º 5
0
def test_all_flags_exist():
    """Aggregate results from previous day"""
    from_date = date(2014, 8, 1)
    to_date = from_date + timedelta(1)
    events =  [
        (date(2014,  8,  2),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),1,"DISPATCH"),
        (date(2014,  8,  1),-1,"DISPATCH"),
        (date(2014,  8,  1),1,"WITH_CUSTOMER"),
        (date(2014,  8,  2),1,"WITH_CUSTOMER"),
        (date(2014,  8,  2),1,"EXTRACT"),
        (date(2014,  7,  2),1,"RECEIPT_EMAIL"),
        (date(2014,  7,  2),-1,"RECEIPT_EMAIL"),
    ]
    result = do_report(from_date, to_date, events)
    assert result == [
                    {"DISPATCH":2, "WITH_CUSTOMER":1, "EXTRACT":0, "RECEIPT_EMAIL":0},
                    {"DISPATCH":1, "WITH_CUSTOMER":2, "EXTRACT":1, "RECEIPT_EMAIL":0},
                    ]
Ejemplo n.º 6
0
def test_no_events():
    """No events, but the resulting list should still have an entry for each date"""
    from_date = date(2014, 8, 2)
    to_date = from_date + timedelta(2)
    result = do_report(from_date, to_date, [])
    assert result == [{}, {}, {},]
Ejemplo n.º 7
0
def test_null():
    """to_date before from_date returns empty list"""
    from_date = date(2014, 8, 2)
    to_date = date(2014, 8, 1)
    result = do_report(from_date, to_date, [])
    assert result == []
Ejemplo n.º 8
0
 def test_null(self):
     """to_date before from_date returns empty list"""
     from_date = date(2014, 8, 2)
     to_date = date(2014, 8, 1)
     result = do_report(from_date, to_date, [])
     self.assertEqual(result, [])