'''Test Github API''' from pulsar.apps.http.auth import HTTPBasicAuth from lux.utils import test from lux.extensions.services import api @test.skipUnless(test.get_params('GITHUB_USERNAME', 'GITHUB_PASSWORD', 'GITHUB_CLIENT_ID', 'GITHUB_CLIENT_SECRET'), 'github_token required in test_settings.py file.') class TestGithub(test.TestCase): auth = None @classmethod def basic(cls): cfg = cls.cfg return HTTPBasicAuth(cfg.get('GITHUB_USERNAME'), cfg.get('GITHUB_PASSWORD')) @classmethod def setUpClass(cls): cfg = cls.cfg cls.g = api('github', cfg) cls.auth = yield cls.g.authorization( note='Lux github test', pre_request=cls.basic(), scopes=['user', 'repo', 'gist']) cls.github = g
'''Test CouchDB client.''' from pulsar.utils.security import random_string, ascii_letters from pulsar.apps.data import create_store from lux.utils import test @test.skipUnless(test.get_params('COUCHDB_SETTINGS'), 'COUCHDB_SETTINGS required in test_settings.py file.') class TestCase(test.TestCase): @classmethod def setUpClass(cls): cls.client = CouchDb(cls.cfg.get('COUCHDB_SETTINGS')) cls.test_id = ('test_%s' % random_string(length=10)).lower() cls.created = [] @classmethod def tearDownClass(cls): for db in cls.created: try: yield cls.client.deletedb(db) except CouchDbError: pass @classmethod def name(cls, name): return '%s_%s' % (cls.test_id, name) @classmethod def createdb(cls, name): name = cls.name(name)
'''Test Github API''' from pulsar import get_actor from pulsar.apps.http.auth import HTTPBasicAuth from pulsar.apps.test import unittest from lux.utils import test from lux.extensions.services import api @test.skipUnless(test.get_params('DROPBOX_CLIENT_ID', 'DROPBOX_CLIENT_SECRET'), 'DROPBOX_* required in config.py file.') class TestDropbox(test.TestCase): auth = None @classmethod def setUpClass(cls): cfg = cls.cfg d = Dropbox(client_id=cfg.get('DROPBOX_CLIENT_ID'), client_secret=cfg.get('DROPBOX_CLIENT_SECRET')) cls.auth = yield d.authorization(response_type='code') #cls.auth = yield d.authorization(response_type='code', # redirect_uri='http://localhost:8060/') cls.dropbox = d def test_authorization(self): auth = self.auth self.assertTrue('id' in auth) self.assertTrue('token' in auth) self.assertEqual(auth['note'], 'Lux github test')
from lux.utils import test from lux.extensions.services import api @test.skipUnless(test.get_params('AMAZON_CLIENT_ID', 'AMAZON_CLIENT_SECRET'), 'amazon_id & amazon_secret parameters required in' ' test_settings.py file.') class TestAmazon(test.TestCase): @classmethod def setUpClass(cls): cls.g = api('amazon', cfg) r = g.authorization(note=cls.note) cls.auth_result = r cls.g = g
'''Test PostgreSQL client.''' from pulsar.utils.security import random_string, ascii_letters from pulsar.apps.data import create_store from lux.utils import test @test.skipUnless(test.get_params('POSTGRESQL_SETTINGS'), 'POSTGRESQL_SETTINGS required in test_settings.py file.') class TestCase(test.TestCase): @classmethod def setUpClass(cls): cls.test_id = ('test_%s' % random_string(length=10)).lower() def abc(self): _, address, params = parse_connection_string( cls.cfg.get('POSTGRESQL_SETTINGS'), 0) cls.pool = PostgresPool() cls.client1 = cls.pool(address, **params) cls.test_id = ('test_%s' % random_string(length=10)).lower() cls.created = [] yield cls.createdb('test1') params['db'] = cls.name('test1') cls.client = cls.pool(address, **params) @classmethod def __tearDownClass(cls): for db in cls.created: try: yield cls.client1.deletedb(db)
'''Geonamesb API''' from lux.utils import test from lux.extensions.services import api @test.skipUnless(test.get_params('GEONAMES_USERNAME'), 'GEONAMES_USERNAME required in config.py file.') class TestGeoNames(test.TestCase): note = 'testing python social package' @classmethod def setUpClass(cls): cls.g = api('geonames', cls.cfg) def setUp(self): self.assertTrue(self.g.has_registration(self.cfg)) def testCountryInfo(self): c = self.g.country_info() self.assertTrue(isinstance(c, list))
'''Test CouchDB client.''' from pulsar.utils.security import random_string, ascii_letters from pulsar.apps.data import create_store from lux.utils import test @test.skipUnless(test.get_params('COUCHDB_SETTINGS'), 'COUCHDB_SETTINGS required in test_settings.py file.') class TestCase(test.TestCase): @classmethod def setUpClass(cls): cls.client = CouchDb(cls.cfg.get('COUCHDB_SETTINGS')) cls.test_id = ('test_%s' % random_string(length=10)).lower() cls.created = [] @classmethod def tearDownClass(cls): for db in cls.created: try: yield cls.client.deletedb(db) except CouchDbError: pass @classmethod def name(cls, name): return '%s_%s' % (cls.test_id, name) @classmethod def createdb(cls, name):