예제 #1
0
def test_negative_price_initialization():
    lesson_str = """{
          "title": "iPhone X",
          "price": -100,
          "location": {
            "address": "город Самара, улица Мориса Тореза, 50",
            "metro_stations": ["Спортивная", "Гагаринская"]
          }
        }"""
    with pytest.raises(ValueError):
        advert.Advert(json.loads(lesson_str))
예제 #2
0
def test_address():
    lesson_str = """{
          "title": "iPhone X", 
          "price": 100,
          "location": {
            "address": "город Самара, улица Мориса Тореза, 50",
            "metro_stations": ["Спортивная", "Гагаринская"]
          }
        }"""
    obj = advert.Advert(json.loads(lesson_str))
    expected = "город Самара, улица Мориса Тореза, 50"
    assert obj.location.address == expected
예제 #3
0
def test_setting_a_negative_price():
    lesson_str = """{
          "title": "iPhone X",
          "price": 100,
          "location": {
            "address": "город Самара, улица Мориса Тореза, 50",
            "metro_stations": ["Спортивная", "Гагаринская"]
          }
        }"""
    obj = advert.Advert(json.loads(lesson_str))
    with pytest.raises(ValueError):
        obj.price = -1