def main(): """Preload the website with some data.""" # clear out existing data delete_all_data() for user_data in SAMPLE_USERS: username = user_data["username"] password = user_data["password"] email = user_data["email"] first_name, last_name = user_data["full_name"].split() create_test_user(username, email, first_name, last_name, password=password) auth_info = dict(username=username, password=password) add_auth_info_to_keyfile(username, auth_info)
def main(): """Preload the website with some data.""" #clear out existing data delete_all_data() for user_data in SAMPLE_USERS: username = user_data['username'] password = user_data['password'] email = user_data['email'] first_name, last_name = user_data['full_name'].split() create_test_user(username, email, first_name, last_name, password=password) auth_info = dict(username=username, password=password) add_auth_info_to_keyfile(username, auth_info)
def setUp(self): """Set up.""" res = super(AuthTestCase, self).setUp() self.auth = auth_backend.Auth() self.auth_parameters = dict(username=u"user", password='******') self.usr = create_test_user(**self.auth_parameters) return res
def main(test_filter, repeat=False): """Main function.""" all_tests = get_all_tests(test_filter) prefix = 'main:' timestamp = time.strftime("%Y%m%d%M%H%S") # create user user1 = "integtest" + timestamp user2 = "integotro" + timestamp for u in (user1, user2): create_test_user(u) debug(prefix, 'User created:', u) debug(prefix, 'Content blobs created') sd1 = SyncDaemon(user1, 1, timestamp, verbose=True) debug(prefix, 'SyncDaemon 1 created.') sd2 = SyncDaemon(user1, 2, timestamp, verbose=True) debug(prefix, 'SyncDaemon 2 created.') sd3 = SyncDaemon(user2, 3, timestamp, verbose=True) debug(prefix, 'SyncDaemon 2 created.') yield sd1.start() debug(prefix, 'SyncDaemon 1 started.') yield sd2.start() debug(prefix, 'SyncDaemon 2 started.') yield sd3.start() debug(prefix, 'SyncDaemon 3 started.') try: if repeat: i = 0 while True: i += 1 debug(prefix, 'Executing tests, run', i) yield execute_tests(all_tests, sd1, sd2, sd3) else: yield execute_tests(all_tests, sd1, sd2, sd3) debug(prefix, 'Tests executed.') except Exception, e: print '\n', '!' * 20, 'There was a problem. Failure below.', '!' * 20 print e print '!' * 20, 'There was a problem. Failure above.', '!' * 20
def setUp(self): """Setup.""" yield super(TestWithDatabase, self).setUp() self.__root = None # Patch AQ's deferreds, to support these tests still being run # in Lucid, but while code calls .cancel() on them # Remove this code when filesync project is taken to Precise. defer.Deferred.cancel = lambda self: None defer.DeferredList.cancel = lambda self: None # Set up the main loop and bus connection self.loop = DBusGMainLoop(set_as_default=True) bus_address = os.environ.get('DBUS_SESSION_BUS_ADDRESS', None) self.bus = dbus.bus.BusConnection(address_or_type=bus_address, mainloop=self.loop) # Monkeypatch the dbus.SessionBus/SystemBus methods, to ensure we # always point at our own private bus instance. self.patch(dbus, 'SessionBus', lambda: self.bus) self.patch(dbus, 'SystemBus', lambda: self.bus) self.nm = FakeNetworkManager(self.bus) self.addCleanup(self.nm.shutdown) # start the ssl proxy self.ssl_service = ssl_proxy.ProxyService( self.ssl_cert, self.ssl_key, self.ssl_cert_chain, 0, # port "localhost", self.port, "ssl-proxy-test", 0) self.patch(config.ssl_proxy, "heartbeat_interval", self.ssl_proxy_heartbeat_interval) yield self.ssl_service.startService() # these tests require a "test" bucket to be avaialble, # but don't create it using the s3 api... self.s4_site.resource._add_bucket("test") if os.path.exists(self.tmpdir): self.rmtree(self.tmpdir) _user_data = [ (u'jack', u'jackpass', u'shard0'), (u'jane', u'janepass', u'shard1'), (u'john', u'johnpass', u'shard2'), ] self.access_tokens = {} self.storage_users = {} for username, password, shard in _user_data: self.access_tokens[username] = { 'username': username, 'password': password, } user = create_test_user(username=username, password=password, shard_id=shard) self.storage_users[username] = user self.dns_srv = None # override and cleanup user config self.old_get_config_files = main.config.get_config_files main.config.get_config_files = lambda: SD_CONFIGS main.config._user_config = None user_config = main.config.get_user_config() for section in user_config.sections(): user_config.remove_section(section) main.config.get_user_config().set_throttling_read_limit(-1) main.config.get_user_config().set_throttling_write_limit(-1) main.config.get_user_config().set_autoconnect(False) # logging can not be configured dinamically, touch the general logger # to get one big file and be able to get the logs if failure logger.init() logger.set_max_bytes(0) yield self.client_setup()
def setUp(self): """Setup.""" yield super(TestWithDatabase, self).setUp() self.__root = None # Patch AQ's deferreds, to support these tests still being run # in Lucid, but while code calls .cancel() on them # Remove this code when filesync project is taken to Precise. defer.Deferred.cancel = lambda self: None defer.DeferredList.cancel = lambda self: None # Set up the main loop and bus connection self.loop = DBusGMainLoop(set_as_default=True) bus_address = os.environ.get('DBUS_SESSION_BUS_ADDRESS', None) self.bus = dbus.bus.BusConnection(address_or_type=bus_address, mainloop=self.loop) # Monkeypatch the dbus.SessionBus/SystemBus methods, to ensure we # always point at our own private bus instance. self.patch(dbus, 'SessionBus', lambda: self.bus) self.patch(dbus, 'SystemBus', lambda: self.bus) self.nm = FakeNetworkManager(self.bus) self.addCleanup(self.nm.shutdown) # start the ssl proxy self.ssl_service = ssl_proxy.ProxyService(self.ssl_cert, self.ssl_key, self.ssl_cert_chain, 0, # port "localhost", self.port, "ssl-proxy-test", 0) self.patch(config.ssl_proxy, "heartbeat_interval", self.ssl_proxy_heartbeat_interval) yield self.ssl_service.startService() # these tests require a "test" bucket to be avaialble, # but don't create it using the s3 api... self.s4_site.resource._add_bucket("test") if os.path.exists(self.tmpdir): self.rmtree(self.tmpdir) _user_data = [ (u'jack', u'jackpass', u'shard0'), (u'jane', u'janepass', u'shard1'), (u'john', u'johnpass', u'shard2'), ] self.access_tokens = {} self.storage_users = {} for username, password, shard in _user_data: self.access_tokens[username] = { 'username': username, 'password': password, } user = create_test_user(username=username, password=password, shard_id=shard) self.storage_users[username] = user self.dns_srv = None # override and cleanup user config self.old_get_config_files = main.config.get_config_files main.config.get_config_files = lambda: SD_CONFIGS main.config._user_config = None user_config = main.config.get_user_config() for section in user_config.sections(): user_config.remove_section(section) main.config.get_user_config().set_throttling_read_limit(-1) main.config.get_user_config().set_throttling_write_limit(-1) main.config.get_user_config().set_autoconnect(False) # logging can not be configured dinamically, touch the general logger # to get one big file and be able to get the logs if failure logger.init() logger.set_max_bytes(0) yield self.client_setup()