def model_serialization_test(self): server_info = ServerInfo(ClientVersion("0.9"), 'Hey!', "0.9") now = datetime.datetime.utcnow() info = UpdateInfo(server_info, now) seri = info.serialize() dese = UpdateInfo.deserialize(seri) self.assertEquals(info, dese)
def test_save_and_load(self): server_info = ServerInfo(ClientVersion("0.9"), 'Hey!', "0.9") now = datetime.datetime.utcnow() info = UpdateInfo(server_info, now) self.store.save(info) self.assertTrue(os.path.exists(self.file_path)) update_info = self.store.load() self.assertEquals(update_info.server_info, server_info) self.assertEquals(update_info.time, info.time)
def test_higher_version_ok(self): server_info = ServerInfo(version="0.9", message='Hey!', last_compatible="0.5") self.biiapi.get_server_info = Mock(return_value=server_info) manager = UpdatesManager(self.store, self.biiapi, ClientVersion("1.0")) last_time = self._save_info(manager, server_info, datetime.timedelta(days=-365)) biiout = OutputStream() manager.check_for_updates(biiout) self.assert_not_in_response(biiout, "There is a new version of biicode")
def test_not_checked_ever(self): """Even out client is obsolete its not time to check yet""" server_info = ServerInfo("0.9", 'Hey!', "0.9") self.biiapi.get_server_info = Mock(return_value=server_info) obsolete_client = ClientVersion("0.8") manager = UpdatesManager( self.store, self.biiapi, obsolete_client, time_between_checks=datetime.timedelta(days=10)) self.assertRaises(ObsoleteClient, manager.check_for_updates, self.user_io.out) self.assertEquals(self.user_io.out.stream.buf, "") # Information is saved self.assertEquals(self.store.load().server_info, server_info) # Now check again (not needed), it must be the same info and get_server_info # was not called self.biiapi.get_server_info.call_count = 0 self.assertRaises(ObsoleteClient, manager.check_for_updates, self.user_io.out) self.assertEquals(self.biiapi.get_server_info.call_count, 0) self.assertEquals(self.store.load().server_info, server_info)
BII_SSL_ENABLED = get_env('BII_SSL_ENABLED', False) BII_SMTP_SERVER = get_env('BII_SMTP_SERVER', 'smtp.gmail.com') BII_SMTP_PORT = get_env('BII_SMTP_PORT', 587) BII_SMTP_USER = get_env('MANDRILL_USERNAME', '*****@*****.**') BII_SMTP_PASSWORD = get_env('MANDRILL_APIKEY', 'fakepass') BII_SMTP_USE_TLS = get_env('BII_SMTP_USE_TLS', True) BII_DEFAULT_FROM_EMAIL = get_env('BII_DEFAULT_FROM_EMAIL', "*****@*****.**") BII_PRODUCTION_ENVIRONMENT = get_env('BII_PRODUCTION_ENVIRONMENT', False) REDIS_URL = get_env('REDISTOGO_URL', 'redis://*****:*****@biicode.com") BII_NAME_FROM = get_env('BII_NAME_FROM', "Biicode") # Secret for generate email confirmation tokens BII_JWT_SECRET_MAIL_CONFIRMATION = get_env('BII_JWT_SECRET_MAIL_CONFIRMATION', "fakekeyfordevelop")
def get_updates_manager(biiapi, biicode_folder): file_store = os.path.join(biicode_folder, ".remote_version_info") updates_store = UpdatesStore(file_store) current_client = ClientVersion(get_current_client_version()) manager = UpdatesManager(updates_store, biiapi, current_client) return manager