Beispiel #1
0
def test_basic(mocked_get_t, monkeypatch):
    monkeypatch.setattr(requests, 'get', mocked_get_t)
    hero = Hero('Mars', token='aoiwdjawodijadw1234')
    assert hero.data == mocked_get_t().json()
    assert hero.__repr__() == '<Hero {}>'.format(hero.name)
    assert hero.__str__() == 'Герой {}'.format(hero.name)
    assert hero.__getattribute__('_Hero__get_data')() == mocked_get_t().json()
    assert hero.token.startswith('****') and hero.token.endswith('1234')

    assert hero.threshold == 300
    hero.threshold = 200
    assert hero.threshold == 200

    hero.data['gender'] = 'female'
    assert hero.__str__() == 'Героиня {}'.format(hero.name)
Beispiel #2
0
def test_tokenized_exceptions(name, mocked_get, monkeypatch):
    monkeypatch.setattr(requests, 'get', mocked_get)
    hero = Hero('Mars')
    with pytest.raises(errors.NeedToken):
        hero.__getattribute__(name)