django.utils.timezone. - python examples

Here are the examples of the python api django.utils.timezone. taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10 Examples 7

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_get_rates_inconsistent_scorelog_rates(member, store0):
    USER_RATE_ONE = 0.5
    USER_RATE_TWO = 0.2

    # Set some rate
    member.rate = USER_RATE_ONE
    member.review_rate = USER_RATE_ONE
    member.save()

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
@pytest.mark.parametrize('task_type, task_type_name, user_rate_attr_name', [
    (PaidTaskTypes.TRANSLATION, 'TRANSLATION', 'rate'),
    (PaidTaskTypes.REVIEW, 'REVIEW', 'review_rate'),
])
def test_invoice_get_rates_inconsistent_paidtask_rates(member, task_type,
                                                       task_type_name,
                                                       user_rate_attr_name,
                                                       store0):
    USER_RATE = 0.5
    PAID_TASK_RATE = 0.2

    # Set some user rate
    setattr(member, user_rate_attr_name, USER_RATE)
    member.save()

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_get_rates_inconsistent_hourly_paidtask_rates(member):
    PAID_TASK_RATE_ONE = 0.5
    PAID_TASK_RATE_TWO = 0.2

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
@pytest.mark.parametrize('task_type, task_type_name, user_rate_attr_name', [
    (PaidTaskTypes.TRANSLATION, 'TRANSLATION', 'rate'),
    (PaidTaskTypes.REVIEW, 'REVIEW', 'review_rate'),
])
def test_invoice_get_rates_scorelog_rates(member, task_type, task_type_name,
                                          user_rate_attr_name, store0):
    """Tests that `Invoice.get_rates()` returns the rates set for users in their
    `ScoreLog` entries.
    """
    USER_RATE_ONE = 0.5
    USER_RATE_TWO = 0.2

    # Set some user rate
    setattr(member, user_rate_attr_name, USER_RATE_ONE)
    member.save()

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_get_rates_paidtask_rates(member):
    """Tests that `Invoice.get_rates()` returns the rates set for users in their
    `PaidTask` entries.
    """
    USER_RATE_ONE = 0.5
    USER_RATE_TWO = 0.2

    # Set some user rate
    member.hourly_rate = USER_RATE_ONE
    member.save()

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_get_rates_user(member):
    """Tests that `Invoice.get_rates()` returns the rates set for users in their
    user model.
    """
    USER_RATE = 0.5

    # Set some user rate
    member.rate = USER_RATE
    member.review_rate = USER_RATE
    member.hourly_rate = USER_RATE
    member.save()

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
@pytest.mark.parametrize('task_type', (PaidTaskTypes.TRANSLATION,
                                       PaidTaskTypes.REVIEW,
                                       PaidTaskTypes.HOURLY_WORK,
                                       PaidTaskTypes.CORRECTION))
@pytest.mark.parametrize('action_code', (TranslationActionCodes.NEW,
                                         TranslationActionCodes.REVIEWED))
def test_invoice_get_user_amounts(member, action_code, task_type):
    """Tests that `Invoice._get_user_amounts()` returns the total amount of work
    performed for the given user when their activities were recorded via both
    score logs and paid tasks.
    """
    from pootle_statistics.models import Submission
    EVENT_COUNT = 5
    WORDCOUNT = 5
    TASK_COUNT = 5
    PAID_TASK_AMOUNT = 22
    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_generate_add_carry_over(member, invoice_directory):
    """Tests that generating invoices multiple times for the same month + user
    will add carry-over corrections only once.
    """
    from pootle_statistics.models import Submission
    EVENT_COUNT = 5
    WORDCOUNT = 5
    TRANSLATION_RATE = 0.5
    INITIAL_SUBTOTAL = EVENT_COUNT * WORDCOUNT * TRANSLATION_RATE
    MINIMAL_PAYMENT = 20

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_generate_negative_balance(member, invoice_directory):
    """Tests that generated invoices that resulted in a negative balance (debt)
    are carried over the next month.
    """
    from pootle_statistics.models import Submission

    WORDCOUNT = 5
    TRANSLATION_RATE = 5
    WORK_DONE = WORDCOUNT * TRANSLATION_RATE
    CORRECTION = -100
    SUBTOTAL = WORK_DONE + CORRECTION

    month = timezone.datetime(2014, 04, 01)

3 View Complete Implementation : invoice.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.django_db
def test_invoice_generate_balance_with_carry_over(member, invoice_directory):
    """Tests that balance is properly reported even if a carry-over already
    existed.
    """
    from pootle_statistics.models import Submission

    WORDCOUNT = 5
    TRANSLATION_RATE = 5
    WORK_DONE = WORDCOUNT * TRANSLATION_RATE
    CORRECTION = -100
    SUBTOTAL = WORK_DONE + CORRECTION
    month = timezone.datetime(2014, 04, 01)