コード例 #1
0
ファイル: advert_test.py プロジェクト: Pashayam/pythonLabs
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
ファイル: advert_test.py プロジェクト: Pashayam/pythonLabs
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
ファイル: advert_test.py プロジェクト: Pashayam/pythonLabs
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