def test_bad_arc(talker: Session) -> None: """Test for bad arc requests.""" with requests_mock.Mocker() as r: r.get( "https://metron.cloud/api/arc/-8/", text='{"response_code": 404, "detail": "Not found."}', ) with pytest.raises(exceptions.ApiError): talker.arc(-8)
def test_bad_arc_validate(talker: Session) -> None: """Test data with invalid data.""" # Change the 'name' field to an int, when it should be a string. data = { "id": 5, "name": 10, "desc": "Foo Bar", "image": "https://static.metron.cloud/media/arc/2018/11/25/ff-26.jpg", "modified": "2019-06-23T15:13:19.432378-04:00", } with requests_mock.Mocker() as r: r.get( "https://metron.cloud/api/arc/500/", text=json.dumps(data), ) with pytest.raises(exceptions.ApiError): talker.arc(500)
def test_known_arc(talker: Session) -> None: """Test for known arcs.""" heroes = talker.arc(1) assert heroes.name == "Heroes In Crisis" assert ( heroes.image == "https://static.metron.cloud/media/arc/2018/11/12/heroes-in-crisis.jpeg" ) assert heroes.modified == datetime( 2019, 6, 23, 15, 13, 19, 456634, tzinfo=timezone(timedelta(days=-1, seconds=72000), "-0400"), )