parent
e0541b7316
commit
097aa7514f
15 changed files with 281 additions and 43 deletions
@ -0,0 +1,69 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
import pytest |
||||||
|
|
||||||
|
from freezegun import freeze_time |
||||||
|
|
||||||
|
from django.utils import timezone |
||||||
|
|
||||||
|
from customer import consts |
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('status', range(1, 5)) |
||||||
|
@pytest.mark.django_db |
||||||
|
def test_license_get_term(lic, status): |
||||||
|
lic.status = status |
||||||
|
lic.save() |
||||||
|
assert 'дней' not in lic.get_term() |
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('status', [0, 1, 4]) |
||||||
|
@pytest.mark.django_db |
||||||
|
def test_license_account_status(lic, status): |
||||||
|
lic.status = status |
||||||
|
lic.save() |
||||||
|
assert lic.account_status != '' |
||||||
|
if status == consts.STATUS_PAID: |
||||||
|
assert 'не' not in lic.account_status |
||||||
|
else: |
||||||
|
assert 'не' in lic.account_status |
||||||
|
|
||||||
|
|
||||||
|
@freeze_time("2017-06-20 00:21:34", tz_offset=2) |
||||||
|
@pytest.mark.django_db |
||||||
|
def test_license_account_sub_status_freeze(lic): |
||||||
|
lic.status = consts.STATUS_FROZEN |
||||||
|
lic.order_date = timezone.now() |
||||||
|
lic.save() |
||||||
|
assert lic.account_sub_status == 'Счет заморожен 25.06.2017' |
||||||
|
|
||||||
|
|
||||||
|
@freeze_time("2017-06-25 00:21:34", tz_offset=2) |
||||||
|
@pytest.mark.parametrize('days', range(1, 6)) |
||||||
|
@pytest.mark.django_db |
||||||
|
def test_license_account_sub_status_not_paid(lic, days): |
||||||
|
lic.status = consts.STATUS_NOT_PAID |
||||||
|
lic.order_date = timezone.now().date() - timezone.timedelta(days) |
||||||
|
lic.save() |
||||||
|
if days != 5: |
||||||
|
assert f'{5 - days}' in lic.account_sub_status |
||||||
|
else: |
||||||
|
assert 'будет заморожен' in lic.account_sub_status |
||||||
|
|
||||||
|
|
||||||
|
@freeze_time("2017-06-25 00:21:34", tz_offset=2) |
||||||
|
@pytest.mark.parametrize('days', range(1, 6)) |
||||||
|
@pytest.mark.django_db |
||||||
|
def test_license_status_need_to_change(lic, days): |
||||||
|
lic.status = consts.STATUS_NOT_PAID |
||||||
|
lic.order_date = timezone.now().date() - timezone.timedelta(days) |
||||||
|
lic.save() |
||||||
|
if days > 5: |
||||||
|
assert lic.status_need_to_change is True |
||||||
|
else: |
||||||
|
assert lic.status_need_to_change is False |
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db |
||||||
|
def test_license_set_freeze_status(lic): |
||||||
|
lic.set_freeze_status() |
||||||
|
assert lic.status is consts.STATUS_FROZEN |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
{% extends "base.html" %} |
||||||
|
{% load pytils_numeral %} |
||||||
|
{% block title %}Лицензии и расчёты{% endblock %} |
||||||
|
|
||||||
|
{% block content %} |
||||||
|
<h1>Лицензии и расчёты</h1> |
||||||
|
<div class="btn yellow-btn docs-btn"><a href="{% url 'customer_order_license' %}">Купить лицензию</a></div> |
||||||
|
<table id="history" class="list"> |
||||||
|
{% for object in object_list %} |
||||||
|
<tr class='{% if object.type %}account_{% else %}license_{% endif %}{{ object.id }}'> |
||||||
|
<td>{{ object.order_date }}</td> |
||||||
|
<td> |
||||||
|
{% if object.type %} |
||||||
|
<p>Счет № {{object.id}} - Лицензия на {{ object.get_term }}, |
||||||
|
{% if object.pay_sum > 0 %}{{ object.pay_sum|get_plural:"рубль,рубля,рублей" }}{% else %}бесплатно{% endif %}</p> |
||||||
|
<p>{% if object.paid_date %}{{ object.get_payform_display }}{% else %}{{ object.get_action_link|safe }}{% endif %}</p> |
||||||
|
{% else %} |
||||||
|
<p>Лицензия № {{object.id}} на {{ object.get_term }}, |
||||||
|
{% if object.pay_sum > 0 %}{{ object.pay_sum|get_plural:"рубль,рубля,рублей" }}{% else %}бесплатно{% endif %}</p> |
||||||
|
<p>{% if object.term > 0 %}{{ object.get_action_link|safe }}{% else %}Пробный период{% endif %}</p> |
||||||
|
{% endif %} |
||||||
|
</td> |
||||||
|
<td> |
||||||
|
{% if object.type %} |
||||||
|
<p>{{ object.account_status }} {% if object.paid_date %}{{ object.paid_date }}{% endif %}</p> |
||||||
|
<p>{% if object.paid_date %}Выдана лицензия № {{ object.id }}{% else %}{{ object.account_sub_status }}{% endif %}</p> |
||||||
|
{% else %} |
||||||
|
<p>{{ object.get_paid_status }}</p> |
||||||
|
<p>Период действия: {% if object.date_from %}{{ object.date_from }} - {{ object.date_to }}{% else %}-{% endif %}</p> |
||||||
|
{% endif %} |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</table> |
||||||
|
{% endblock content %} |
||||||
Loading…
Reference in new issue