예제 #1
0
def test_import_not_in_test_mode(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['testmode'] = False
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    assert not event.orders.last().testmode
예제 #2
0
def test_name_parts(user, event, item):
    event.settings.name_scheme = 'given_family'
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['email'] = 'csv:C'
    settings['invoice_address_name_given_name'] = 'csv:A'
    settings['invoice_address_name_family_name'] = 'csv:B'
    settings['attendee_name_given_name'] = 'csv:A'
    settings['attendee_name_family_name'] = 'csv:B'
    import_orders.apply(
        args=(event.pk, inputfile_factory().id, settings, 'en', user.pk)
    ).get()
    o = event.orders.get(email='*****@*****.**')
    assert o.invoice_address.name_parts == {
        '_scheme': 'given_family',
        'given_name': 'Dieter',
        'family_name': 'Schneider'
    }
    assert o.invoice_address.name_cached == 'Dieter Schneider'
    assert o.positions.first().attendee_name_parts == {
        '_scheme': 'given_family',
        'given_name': 'Dieter',
        'family_name': 'Schneider'
    }
    assert o.positions.first().attendee_name_cached == 'Dieter Schneider'
예제 #3
0
def test_import_simple(event, item, user):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    assert event.orders.count() == 3
    assert OrderPosition.objects.count() == 3
예제 #4
0
def test_import_secret(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['secret'] = 'csv:A'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk)).get()
    assert OrderPosition.objects.filter(secret="Dieter").count() == 1
예제 #5
0
def test_import_product_unknown(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'csv:A'
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Dieter" for column "Product" in line "1": No matching product was found.' in str(
        excinfo.value)
예제 #6
0
def test_import_as_one_order(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['orders'] = 'one'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    assert event.orders.count() == 1
    o = event.orders.get()
    assert o.positions.count() == 3
예제 #7
0
def test_variation_required(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    item.variations.create(value='Default')
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "" for column "Product variation" in line "1": You need to select a variation for this product.' in str(
        excinfo.value)
예제 #8
0
def test_import_attendee_email_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['attendee_email'] = 'csv:A'
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Dieter" for column "Attendee e-mail address" in line "1": Enter a valid email address.' in str(
        excinfo.value)
예제 #9
0
def test_import_email(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['email'] = 'csv:C'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    assert event.orders.filter(email="*****@*****.**").exists()
    assert event.orders.filter(email="*****@*****.**").exists()
    assert event.orders.filter(email__isnull=True).count() == 1
예제 #10
0
def test_import_price_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['price'] = 'csv:A'
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Dieter" for column "Price" in line "1": You ' \
           'entered an invalid number.' in str(excinfo.value)
예제 #11
0
def test_import_saleschannel_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['sales_channel'] = 'csv:A'
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Dieter" for column "Sales channel" in line "1": Please enter a valid sales channel.' in str(
        excinfo.value)
예제 #12
0
def test_import_country(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['invoice_address_country'] = 'csv:G'
    settings['email'] = 'csv:C'
    import_orders.apply(
        args=(event.pk, inputfile_factory().id, settings, 'en', user.pk)
    )
    assert str(event.orders.get(email='*****@*****.**').invoice_address.country) == 'US'
예제 #13
0
def test_import_secret_dupl(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['secret'] = 'csv:D'
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Test" for column "Ticket code" in line "2": You cannot assign a position ' \
           'secret that already exists.' in str(excinfo.value)
예제 #14
0
def test_import_locale_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['locale'] = 'static:de'  # not enabled on this event
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "de" for column "Order locale" in line "1": Please enter a valid language code.' in str(
        excinfo.value)
예제 #15
0
def test_import_pending(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['status'] = 'pending'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    o = event.orders.last()
    assert o.status == Order.STATUS_PENDING
    assert o.total == Decimal('23.00')
    assert not o.payments.exists()
예제 #16
0
def test_import_seat_required(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)

    event.seat_category_mappings.create(layout_category='Stalls', product=item)
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "" for column "Seat ID" in line "1": You need to select ' \
           'a specific seat.' in str(excinfo.value)
예제 #17
0
def test_import_country_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['invoice_address_country'] = 'csv:A'
    settings['email'] = 'csv:C'
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Dieter" for column "Invoice address: Country" in line "1": Please enter a valid country code.' in str(
        excinfo.value)
예제 #18
0
def test_variation_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['variation'] = 'csv:E'
    item.variations.create(value='Default')
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Foo" for column "Product variation" in line "1": No matching variation was found.' in str(
        excinfo.value)
예제 #19
0
def test_import_question_validate(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    q = event.questions.create(question='Foo', type=Question.TYPE_NUMBER)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['question_{}'.format(q.pk)] = 'csv:D'

    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Test" for column "Question: Foo" in line "1": Invalid number input.' in str(
        excinfo.value)
예제 #20
0
def test_import_subevent(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    event.has_subevents = True
    event.save()
    s = event.subevents.create(name='Test', date_from=now(), active=True)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['subevent'] = 'csv:D'

    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk)).get()
    assert OrderPosition.objects.filter(subevent=s).count() == 3
예제 #21
0
def test_import_subevent_required(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    event.has_subevents = True
    event.save()
    settings['item'] = 'static:{}'.format(item.pk)

    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "" for column "Date" in line "1": You need to select a date.' in str(
        excinfo.value)
예제 #22
0
def test_import_seat_dbl(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['seat'] = 'csv:D'

    event.seat_category_mappings.create(layout_category='Stalls', product=item)
    event.seats.create(seat_number="Test", product=item, seat_guid="Test")
    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Test" for column "Seat ID" in line "2": The seat you selected has already ' \
           'been taken. Please select a different seat.' in str(excinfo.value)
예제 #23
0
def test_company(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['email'] = 'csv:C'
    settings['invoice_address_company'] = 'csv:C'
    import_orders.apply(
        args=(event.pk, inputfile_factory().id, settings, 'en', user.pk)
    ).get()
    assert event.orders.get(email='*****@*****.**').invoice_address.company == '*****@*****.**'
    assert event.orders.get(email='*****@*****.**').invoice_address.is_business
    assert event.orders.get(email__isnull=True).invoice_address.company == ''
    assert not event.orders.get(email__isnull=True).invoice_address.is_business
예제 #24
0
def test_variation_dynamic(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['variation'] = 'csv:E'
    v1 = item.variations.create(value='Foo')
    v2 = item.variations.create(value=LazyI18nString({'en': 'Bar'}))
    v3 = item.variations.create(value='Baz')
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk)).get()
    assert OrderPosition.objects.filter(variation=v1).count() == 1
    assert OrderPosition.objects.filter(variation=v2).count() == 1
    assert OrderPosition.objects.filter(variation=v3).count() == 1
예제 #25
0
def test_import_phone(user, event, item):
    event.settings.region = 'DE'
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['email'] = 'csv:C'
    settings['phone'] = 'csv:K'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    assert str(event.orders.get(
        email="*****@*****.**").phone) == "+4962213217750"
    assert str(
        event.orders.get(email="*****@*****.**").phone) == "+4962213217750"
    assert event.orders.filter(phone__isnull=True).count() == 1
예제 #26
0
def test_import_subevent_invalid(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    event.has_subevents = True
    event.save()
    event.subevents.create(name='Foo', date_from=now(), active=True)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['subevent'] = 'csv:E'

    with pytest.raises(DataImportError) as excinfo:
        import_orders.apply(args=(event.pk, inputfile_factory().id, settings,
                                  'en', user.pk)).get()
    assert 'Error while importing value "Bar" for column "Date" in line "2": No matching date was found.' in str(
        excinfo.value)
예제 #27
0
def test_import_product(user, event, item):
    i = Item.objects.create(
        event=event,
        name=LazyI18nString({'de': 'Foo', 'en': 'Bar'}),
        internal_name='Baz',
        default_price=23,
    )
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'csv:E'
    import_orders.apply(
        args=(event.pk, inputfile_factory().id, settings, 'en', user.pk)
    )
    assert OrderPosition.objects.filter(item=i).count() == 3
예제 #28
0
def test_import_free(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['price'] = 'csv:F'
    settings['status'] = 'pending'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    o = event.orders.last()
    assert o.status == Order.STATUS_PAID
    assert o.total == Decimal('0.00')
    p = o.payments.first()
    assert p.provider == 'free'
    assert p.state == OrderPayment.PAYMENT_STATE_CONFIRMED
예제 #29
0
def test_import_seat(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['seat'] = 'csv:E'

    event.seat_category_mappings.create(layout_category='Stalls', product=item)
    s1 = event.seats.create(seat_number="Foo", product=item, seat_guid="Foo")
    s2 = event.seats.create(seat_number="Bar", product=item, seat_guid="Bar")
    s3 = event.seats.create(seat_number="Baz", product=item, seat_guid="Baz")
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk)).get()
    assert not s1.is_available()
    assert not s2.is_available()
    assert not s3.is_available()
예제 #30
0
def test_import_paid_generate_invoice(user, event, item):
    settings = dict(DEFAULT_SETTINGS)
    settings['item'] = 'static:{}'.format(item.pk)
    settings['status'] = 'paid'
    event.settings.invoice_generate = 'paid'
    import_orders.apply(args=(event.pk, inputfile_factory().id, settings, 'en',
                              user.pk))
    o = event.orders.last()
    assert o.status == Order.STATUS_PAID
    assert o.total == Decimal('23.00')
    p = o.payments.first()
    assert p.provider == 'manual'
    assert p.state == OrderPayment.PAYMENT_STATE_CONFIRMED
    assert o.invoices.count() == 1