def test_ip_info_add_request_new_session(): ip = "230.90.10.71" time = 1452978709 ip_info = IpInfo(ip, time, inactive_window) ip_info.add_request(time + 1201) expect(ip_info.total_pages).to.eq(2) expect(ip_info.total_sessions).to.eq(2) expect(ip_info.total_time).to.eq(2400) expect(ip_info.avg_pp_session()).to.eq(1.0) expect(ip_info.avg_pp_min()).to.eq(0.05)
def test_ip_info_init(): ip = "127.0.0.1" time = 1452978797 ip_info = IpInfo(ip, time, inactive_window) expect(ip_info.ip).to.eq(ip) expect(ip_info.total_pages).to.eq(1) expect(ip_info.total_sessions).to.eq(1) expect(ip_info.total_time).to.eq(1200) expect(ip_info.avg_pp_session()).to.eq(1) expect(ip_info.avg_pp_min()).to.eq(0.05)
def test_ip_info_add_request_same_session(): ip = "10.7.39.1" time = 1452978000 ip_info = IpInfo(ip, time, inactive_window) ip_info.add_request(time + 1198) ip_info.add_request(time + 1199) expect(ip_info.total_pages).to.eq(3) expect(ip_info.total_sessions).to.eq(1) expect(ip_info.total_time).to.eq(2399) expect(ip_info.avg_pp_session()).to.eq(3.0) expect(ip_info.avg_pp_min()).to.be.within(0.075, 0.0751)