def test_build_fail_no_spec_or_src(self): with pytest.raises(SystemExit): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() build_cmd = ['build', '--app-name', 'MyApp', '--clean' '--app-version', '0.1.0', '-F'] parser = get_parser() args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args) b.build()
def test_make_spec(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() spec_cmd = ['make-spec', 'app.py', '-F', '--app-name', 'MyApp', '--app-version', '0.1.0'] spec_file_name = get_system() + '.spec' build_cmd = ['build', '--app-name', 'MyApp', '--app-version', '0.1.0', spec_file_name] build_cmd = [str(b) for b in build_cmd] parser = get_parser() with open('app.py', 'w') as f: f.write('print "Hello, World!"') args, pyu_args = parser.parse_known_args(spec_cmd) b = Builder(args, pyu_args) b.make_spec() assert os.path.exists(spec_file_name) args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args) b.build() with ChDir(new_folder): assert len(os.listdir(os.getcwd())) == 1
def test_bad_pub_key(self): t_config = TConfig() # If changed ensure it's a valid key format t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM' t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) assert client.update_check(client.app_name, '0.0.0') is None
def test_bad_pub_key(self): t_config = TConfig() # If changed ensure it's a valid key format t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM' t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) assert client.update_check(client.app_name, '0.0.0') is None
def test_make_spec(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() spec_cmd = [ 'make-spec', 'app.py', '-F', '--app-name', 'MyApp', '--app-version', '0.1.0' ] spec_file_name = get_system() + '.spec' build_cmd = [ 'build', '--app-name', 'MyApp', '--app-version', '0.1.0', spec_file_name ] build_cmd = [str(b) for b in build_cmd] parser = get_parser() with open('app.py', 'w') as f: f.write('print "Hello, World!"') args, pyu_args = parser.parse_known_args(spec_cmd) b = Builder(args, pyu_args) b.make_spec() assert os.path.exists(spec_file_name) args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args) b.build() with ChDir(new_folder): assert len(os.listdir(os.getcwd())) == 1
def test_manifest_filesystem(self): t_config = TConfig() t_config.PUBLIC_KEYS = ['bad key'] t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) filesystem_data = client._get_manifest_filesystem() filesystem_data = json.loads(filesystem_data) del filesystem_data['sigs'] assert client.json_data == filesystem_data
def test_no_patch_support(self, db): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir t_config.UPDATE_PATCHES = False config = TransistionDict() config.from_object(t_config) p = PackageHandler(config, db) p.process_packages()
def test_process_packages(self): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir t_config.UPDATE_PATCHES = False config = Config() config.from_object(t_config) p = PackageHandler(config) p.process_packages()
def test_http(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' assert update.download() is True assert update.is_downloaded() is True
def test_no_patch_support(self, db): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir t_config.UPDATE_PATCHES = False config = TransistionDict() config.from_object(t_config) p = PackageHandler(config, db) p.process_packages()
def test_init(self): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir config = Config() config.from_object(t_config) p = PackageHandler(config) assert p.files_dir == os.path.join(data_dir, user_data_dir, "files") assert p.deploy_dir == os.path.join(data_dir, user_data_dir, "deploy")
def test_process_packages(self): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir t_config.UPDATE_PATCHES = False config = Config() config.from_object(t_config) p = PackageHandler(config) p.process_packages()
def test_init(self, db): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir config = TransistionDict() config.from_object(t_config) p = PackageHandler(config, db) assert p.files_dir == os.path.join(data_dir, s_dir, 'files') assert p.deploy_dir == os.path.join(data_dir, s_dir, 'deploy')
def test_init(self): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir config = Config() config.from_object(t_config) p = PackageHandler(config) assert p.files_dir == os.path.join(data_dir, s_dir, 'files') assert p.deploy_dir == os.path.join(data_dir, s_dir, 'deploy')
def test_http(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' assert update.download() is True assert update.is_downloaded() is True
def test_http(client): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.VERIFY_SERVER_CERT = False client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'jms' assert update.download() is True assert update.is_downloaded() is True
def test_manifest_filesystem(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) filesystem_data = client._get_manifest_from_disk() assert filesystem_data is not None filesystem_data = filesystem_data.decode() filesystem_data = json.loads(filesystem_data) del filesystem_data["signature"] assert client.json_data == filesystem_data
def test_manifest_filesystem(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) filesystem_data = client._get_manifest_filesystem() assert filesystem_data is not None if six.PY3: filesystem_data = filesystem_data.decode() filesystem_data = json.loads(filesystem_data) del filesystem_data['signature'] assert client.json_data == filesystem_data
def test_directory_creation(self): data_dir = os.getcwd() pyu_data_dir = os.path.join(data_dir, 'pyu-data') t_config = TConfig() t_config.DATA_DIR = data_dir pyu = PyUpdater(t_config) pyu.setup() assert os.path.exists(pyu_data_dir) assert os.path.exists(os.path.join(pyu_data_dir, 'deploy')) assert os.path.exists(os.path.join(pyu_data_dir, 'files')) assert os.path.exists(os.path.join(pyu_data_dir, 'new'))
def test_callback(self): def cb(status): print(status) def cb2(status): raise IndexError t_config = TConfig() t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM' t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True, progress_hooks=[cb]) client.add_progress_hook(cb2) assert client.update_check(client.app_name, '0.0.0') is None
def test_callback(self): def cb(status): print(status) def cb2(status): raise IndexError t_config = TConfig() t_config.PUBLIC_KEY = '25RSdhJ+xCsxxTjY5jffilatipp29tnKp/D5BelSMJM' t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True, progress_hooks=[cb]) client.add_progress_hook(cb2) assert client.update_check(client.app_name, '0.0.0') is None
def test_callback(self): def cb(status): print(status) def cb2(status): raise IndexError t_config = TConfig() t_config.PUBLIC_KEYS = ['bad key'] t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True, call_back=cb, callbacks=[cb, cb2]) client.add_call_back(cb2) assert client.update_check('jms', '0.0.0') is None
def test_build_fail_no_spec_or_src(self): with pytest.raises(SystemExit): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() build_cmd = [ 'build', '--app-name', 'MyApp', '--clean' '--app-version', '0.1.0', '-F' ] parser = get_parser() args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args) b.build()
def test_async_http(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' update.download(async=True) count = 0 while count < 61: if update.is_downloaded() is True: break time.sleep(1) count += 1 assert update.is_downloaded() is True
def test_background_http(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' update.download(background=True) count = 0 while count < 61: if update.is_downloaded() is True: break time.sleep(1) count += 1 assert update.is_downloaded() is True
def test_build_mac_dot_app(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() build_cmd = ['build', '-F', '-w', '--app-name', 'MyApp', '--app-version', '0.1.0', 'app.py'] build_cmd = [str(b) for b in build_cmd] parser = get_parser() with open('app.py', 'w') as f: f.write('print "Hello, World!"') args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args) b.build() with ChDir(new_folder): assert len(os.listdir(os.getcwd())) == 1
def test_multiple_background_calls(self, client): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.VERIFY_SERVER_CERT = False client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' update.download(background=True) count = 0 assert update.download(background=True) is None assert update.download() is None while count < 61: if update.is_downloaded() is True: break time.sleep(1) count += 1 assert update.is_downloaded() is True
def test_build(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() build_cmd = [ 'build', '--app-name', 'MyApp', '--app-version', '0.1.0', 'app.py' ] build_cmd = [str(b) for b in build_cmd] parser = get_parser() with open('app.py', 'w') as f: f.write('print "Hello, World!"') args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args) b.build() with ChDir(new_folder): assert len(os.listdir(os.getcwd())) == 1
def test_multipule_async_calls(self, client): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.VERIFY_SERVER_CERT = False client = Client(t_config, refresh=True, test=True) update = client.update_check(client.app_name, '0.0.1') assert update is not None assert update.app_name == 'Acme' update.download(async=True) count = 0 assert update.download(async=True) is None assert update.download() is None while count < 61: if update.is_downloaded() is True: break time.sleep(1) count += 1 assert update.is_downloaded() is True
def test_build_fail_script_syntax_error(self): with pytest.raises(SystemExit): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() spec_cmd = ['make-spec', 'app.py', '-F'] spec_file_name = get_system() + '.spec' build_cmd = ['build', '--app-name', 'MyApp', '--clean' '--app-version', '0.1.0', spec_file_name] parser = get_parser() with open('app.py', 'w') as f: # Missing closing quote f.write('print "Hello, World!') args, pyu_args = parser.parse_known_args(spec_cmd) b = Builder(args, pyu_args) b.make_spec() assert os.path.exists(spec_file_name) args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args)
def test_build_fail_script_syntax_error(self): with pytest.raises(SystemExit): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) pyu.setup() spec_cmd = ['make-spec', 'app.py', '-F'] spec_file_name = get_system() + '.spec' build_cmd = [ 'build', '--app-name', 'MyApp', '--clean' '--app-version', '0.1.0', spec_file_name ] parser = get_parser() with open('app.py', 'w') as f: # Missing closing quote f.write('print "Hello, World!') args, pyu_args = parser.parse_known_args(spec_cmd) b = Builder(args, pyu_args) b.make_spec() assert os.path.exists(spec_file_name) args, pyu_args = parser.parse_known_args(build_cmd) b = Builder(args, pyu_args)
def test_urls_tuple_attr(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.UPDATE_URLS = ('http://acme.com/update') client = Client(t_config, test=True) assert isinstance(client.update_urls, list)
def pyu(): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) return pyu
def client(): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) client.FROZEN = True return client
def test_url_str_attr(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.UPDATE_URLS = 'http://acme.com/update' client = Client(t_config, test=True) assert isinstance(client.update_urls, list)
def test_bad_pub_key(self, client): t_config = TConfig() t_config.PUBLIC_KEYS = ['bad key'] t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) assert client.update_check('jms', '0.0.0') is None
def client(): t_config = TConfig() t_config.DATA_DIR = os.getcwd() client = Client(t_config, refresh=True, test=True) client.FROZEN = True return client
def pyu(): t_config = TConfig() t_config.DATA_DIR = os.getcwd() pyu = PyUpdater(t_config) return pyu
def test_url_list_attr(self): t_config = TConfig() t_config.DATA_DIR = os.getcwd() t_config.UPDATE_URL = ['http://acme.com/update'] client = Client(t_config, refresh=True, test=True) assert isinstance(client.update_urls, list)