def test_from_values_per_date(): logo = Logo(**prepare_logo_data('1', starts_at=date(2020, 9, 1), expires_at=date(2020, 10, 1))) metric = LogoMetric.from_values_per_date(logo, 'users', { date(2020, 8, 15): 1000, date(2020, 9, 1): 10, date(2020, 9, 15): 20, date(2020, 10, 1): 30, date(2020, 10, 15): 1000, }) assert metric.logo == logo assert metric.name == 'users' assert metric.value == 10 + 20 + 30
def test_days_until_expires(): logo = Logo(**prepare_logo_data('1', expires_at=date(1987, 9, 8))) assert logo.days_until_expires(today=date(1987, 8, 30)) == 9
def test_expires_soon(today, expected): logo = Logo(**prepare_logo_data('1', starts_at=date(2020, 1, 1), expires_at=date(2020, 7, 1))) assert logo.expires_soon(today=today) is expected
def test_days_since_started(): logo = Logo(**prepare_logo_data('1', starts_at=date(1987, 8, 30))) assert logo.days_since_started(today=date(1987, 9, 8)) == 9