def bead(self, timestamp): tmp = self.new_temp_dir() ws = Workspace(tmp / 'ws') ws.create('a bead kind') bead_archive = tmp / 'bead.zip' ws.pack(bead_archive, timestamp, comment='bead for a shared box') return bead_archive
def run(self, args): extract_output = args.extract_output env = args.get_env() try: bead = resolve_bead(env, args.bead_ref_base, args.bead_time) except LookupError: die('Bead not found!') try: verify_with_feedback(bead) except InvalidArchive: die('Bead is damaged') if args.workspace is DERIVE_FROM_BEAD_NAME: workspace = Workspace(bead.name) else: workspace = args.workspace if os.path.exists(workspace.directory): die(f'Workspace "{workspace.name}" directory already exists' ' - do you have an old checkout?') bead.unpack_to(workspace) assert workspace.is_valid if extract_output: output_directory = workspace.directory / layouts.Workspace.OUTPUT bead.unpack_data_to(output_directory) print(f'Extracted source into {workspace.directory}') # XXX: try to load smaller inputs? if workspace.inputs: print('Input data not loaded, update if needed and load manually')
def make_bead(timestamp): with TempDir() as tempdir_obj: workspace_dir = os.path.join(tempdir_obj.path, bead_name) ws = Workspace(workspace_dir) ws.create(bead_kind) sentinel_file = ws.directory / 'sentinel-{}'.format(timestamp) tech.fs.write_file(sentinel_file, timestamp) tech.fs.write_file(ws.directory / 'output/README', timestamp) box.store(ws, timestamp) tech.fs.rmtree(workspace_dir)
def test_save_stores_bead_in_specified_box(self, robot, box1, box2): robot.cli('new', 'bead') robot.cli('save', box1.name, '--workspace=bead') with robot.environment: kind = Workspace('bead').kind assert 1 == bead_count(box1, kind) assert 0 == bead_count(box2, kind) robot.cli('save', box2.name, '-w', 'bead') assert 1 == bead_count(box1, kind) assert 1 == bead_count(box2, kind)
def test_save_stores_bead_in_specified_box(self, robot, box1, box2): robot.cli('new', 'bead') robot.cli('save', box1.name, '--workspace=bead') with robot.environment: kind = Workspace('bead').kind self.assertEquals(1, bead_count(robot, box1, kind)) self.assertEquals(0, bead_count(robot, box2, kind)) robot.cli('save', box2.name, '-w', 'bead') self.assertEquals(1, bead_count(robot, box1, kind)) self.assertEquals(1, bead_count(robot, box2, kind))
def test_update_unloaded_input_w_another_bead(self, robot, bead_with_inputs, bead_a, bead_b): robot.cli('develop', bead_with_inputs) robot.cd(bead_with_inputs) assert not Workspace(robot.cwd).is_loaded('input_b') robot.cli('input', 'update', 'input_b', bead_a) self.assert_loaded(robot, 'input_b', bead_a) robot.cli('status') self.assertThat(robot.stdout, Not(Contains(bead_b)))
def test_add_with_hacked_bead_is_refused(self, robot, hacked_bead, bead_a): robot.cli('develop', bead_a) robot.cd(bead_a) robot.cli('input', 'add', 'hack', hacked_bead) self.assertFalse(Workspace(robot.cwd).has_input('hack')) self.assertThat(robot.stderr, Contains('WARNING'))