示例#1
0
def test_car_title():
    brand = CarBrandFactory(name='Audi')
    car = CarFactory(model=CarModelFactory(name='A4', brand=brand),
                     extra_title='Best deal')

    assert Car.objects.count() == 1
    assert car.title == 'Audi Best deal'
    assert str(car) == 'Audi Best deal'

    car.extra_title = None
    assert car.title == 'Audi '
示例#2
0
def test_car_title():
    brand = CarBrandFactory(name="Audi")
    car = CarFactory(model=CarModelFactory(name="A4", brand=brand),
                     extra_title="Best deal")

    assert Car.objects.count() == 1
    assert car.title == "Audi Best deal"
    assert str(car) == "Audi Best deal"

    car.extra_title = None
    assert car.title == "Audi "
示例#3
0
def test_car_model_title():
    brand = CarBrandFactory(name="Audi")
    CarFactory(model=CarModelFactory(name="A4", brand=brand),
               extra_title="Best deal")

    car = Car.objects.last()
    assert car.model_brand_title == "Audi A4"
示例#4
0
def test_car_model_title():
    brand = CarBrandFactory(name='Audi')
    CarFactory(model=CarModelFactory(name='A4', brand=brand),
               extra_title='Best deal')

    car = Car.objects.last()
    assert car.model_brand_title == 'Audi A4'
示例#5
0
def test_car_model_title():
    brand = CarBrandFactory(name="Audi")
    car = CarFactory(model=CarModelFactory(name="A4", brand=brand),
                     extra_title="Best deal")

    PhotoFactory(car=car, position=2)
    PhotoFactory(car=car, position=3)
    PhotoFactory(car=car, position=1)

    photos = car.photos.all()
    assert [p.position for p in photos] == [1, 2, 3]
def test_order_create_unique(client):
    car = CarFactory()
    OrderFactory(email='*****@*****.**', car=car)

    data = {
        'first_name': 'Dead',
        'last_name': 'Rabbit',
        'email': '*****@*****.**',
        'car': car.id,
        'phone': '28947842942',
    }

    resp = client.post(path=reverse('orders:create'), data=data)
    assert resp.status_code == 400
    assert Order.objects.count() == 1
def test_order_create(client):
    car = CarFactory()
    data = {
        'first_name': 'Dead',
        'last_name': 'Rabbit',
        'email': '*****@*****.**',
        'car_id': car.id,
        'phone': '28947842942',
    }

    assert Order.objects.count() == 0

    resp = client.post(path=reverse('orders:create'), data=data)
    assert resp.status_code == 201
    orders = Order.objects.all()
    assert len(orders) == 1
    assert orders[0].first_name == 'Dead'
    assert orders[0].last_name == 'Rabbit'
    assert orders[0].email == '*****@*****.**'
    assert orders[0].phone == '28947842942'
    assert orders[0].car_id == car.id