def test_standard_minutes_on_two_days(self): start = parse('01-01-2018 21:57:13Z') end = parse('01-02-2018 6:10:56Z') record = CallRecord(started_at=start, ended_at=end, call_id=uuid.uuid4()) assert record.standard_minutes() == 12
def test_mixed_standard_and_reduced_tariff(self): start = parse('01-01-2018 21:57:13Z') end = parse('01-01-2018 22:10:56Z') record = CallRecord(started_at=start, ended_at=end, call_id=uuid.uuid4()) record.save() assert record.price == 0.36 + 0.09 * 2
def test_standard_call_charges_standing_and_minutely(self): start = parse('01-01-2018 20:55:13Z') end = parse('01-01-2018 20:58:56Z') record = CallRecord(started_at=start, ended_at=end, call_id=uuid.uuid4()) record.save() assert record.price == 0.36 + 0.09 * 3
def test_reduced_tariff_charges_only_standing_charge(self): start = parse('01-01-2018 22:57:13Z') end = parse('01-01-2018 23:10:56Z') record = CallRecord(started_at=start, ended_at=end, call_id=uuid.uuid4()) record.save() assert record.price == 0.36
def test_calculates_duration(self): start = parse('01-01-2018 16:00Z') end = parse('01-01-2018 16:30Z') record = CallRecord(started_at=start, ended_at=end, call_id=uuid.uuid4()) record.save() assert record.duration == timedelta(minutes=30)
def test_standard_minutes_at_same_day(self): record = CallRecord(call_id=uuid.uuid4()) record.started_at = parse('01-01-2018 21:00:00Z') record.ended_at = parse('01-01-2018 22:10:56Z') assert record.standard_minutes() == 60 record.started_at = parse('01-01-2018 21:57:13Z') assert record.standard_minutes() == 2 record.started_at = parse('01-01-2018 22:05:13Z') assert record.standard_minutes() == 0
def fake_call(start, index): return CallRecord(started_at=start, ended_at=start + delta(minutes=random.randint(0, 1000)), call_id=uuid.uuid4(), source=NUMBER1 if index < 10 else NUMBER2, destination=fake_phonenumber(), duration=random_duration(), price=random_price())
def test_record_creation(self): record = CallRecord() record.save() assert record.id