def cin(): return Cinemate( username='******', password='******', passkey='PASSKEY', apikey='APIKEY', )
def setUp(self): self.cin = Cinemate( username='******', password='******', passkey='PASSKEY', apikey='APIKEY', )
class CinemateTestCase(unittest.TestCase): def setUp(self): self.cin = Cinemate( username='******', password='******', passkey='PASSKEY', apikey='APIKEY', ) def test_str(self): self.assertEqual(str(self.cin), '<Cinemate: USERNAME>') @activate def test_api_get(self): register_uri(GET, rr['stats.new']['req'], body=rr['stats.new']['resp']) register_uri(GET, rr['stats.wtf']['req'], body=rr['stats.wtf']['resp']) register_uri(GET, rr['account.wrong_status_code']['req'], body=rr['account.wrong_status_code']['resp'], status=rr['account.wrong_status_code']['status']) correct_url = 'stats.new' incorect_url = 'stats.wtf' req = self.cin.api_get(correct_url) self.assertEqual(req.status_code, codes.ok) self.assertNotIn('error', req.json()) self.assertRaises(RuntimeError, self.cin.api_get, incorect_url) not_found_url = rr['account.wrong_status_code']['req'] self.assertRaises(RuntimeError, self.cin.api_get, not_found_url)
def test_cinemate_wo_params(open_mock, exists_mock, config_content): open_mock.return_value = ContextualStringIO(config_content) exists_mock.return_value = True cin = Cinemate() assert cin.username == 'MOCK_USERNAME' assert cin.password == 'MOCK_PASSWORD' assert cin.passkey == 'MOCK_PASSKEY' assert cin.apikey == 'MOCK_APIKEY'
# coding=utf-8 """ Пример показывает как использовать следующие методы api: * account.auth * account.profile * account.updatelist * account.watchlist """ from cinemate import Cinemate if __name__ == '__main__': cin = Cinemate( 'username', 'password', 'passkey', 'apikey' ) passkey = cin.account.auth() profile = cin.account.profile() updatelist = cin.account.updatelist() watchlist = cin.account.watchlist() print(passkey) print(profile['username']) for update in updatelist: if update['new']: print(update['date']) print(update['date'], update['for_object']) for interesting_person in watchlist['person']: print(interesting_person) for interesting_movie in watchlist['movie']: print(interesting_movie)
def test_cinemate_raise_wo_params(exists_mock): exists_mock.return_value = False with pytest.raises(IOError): Cinemate()