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_execution(self, pyu, db): archive_name = 'myapp-{}-0.1.0{}'.format(get_system(), ext) parser = get_parser() data_dir = pyu.config['DATA_DIR'] pyu_data_dir = os.path.join(data_dir, 'pyu-data') pyu.setup() pyu.make_keys(3) with ChDir(data_dir): loader = Loader(db) loader.save_config(pyu.config.copy()) with open('app.py', 'w') as f: f.write('print "Hello World"') args, pyu_args = parser.parse_known_args(create_build_cmd(0)) b = Builder(args, pyu_args) b.build() assert os.path.exists(os.path.join(pyu_data_dir, 'new', archive_name)) pyu.process_packages() assert os.path.exists(os.path.join(pyu_data_dir, 'deploy', archive_name)) assert os.path.exists(os.path.join(pyu_data_dir, 'files', archive_name)) pyu.sign_update() assert os.path.exists(os.path.join(pyu_data_dir, 'deploy', 'versions.gz'))
def _build(args, pyi_args): check = check_repo() if check is False: _repo_error() builder = Builder(args, pyi_args) builder.build()
def _make_spec(args, pyi_args): check = check_repo() if check is False: _repo_error() builder = Builder(args, pyi_args) builder.make_spec()
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_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_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_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_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_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_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_no_repo(self): with pytest.raises(SystemExit): b = Builder(list(), dict()) b.build()
def _build(args, pyi_args): check_repo() builder = Builder(args, pyi_args) builder.build()
def _make_spec(args, pyi_args): check_repo() builder = Builder(args, pyi_args) builder.make_spec()