def test_default_registry(self): new_pkg = Package() # Create a dummy file to add to the package. test_file_name = 'bar' with open(test_file_name, "w") as fd: fd.write('test_file_content_string') test_file = Path(fd.name) # Build a new package into the local registry. new_pkg = new_pkg.set('foo', test_file_name) top_hash = new_pkg.build("Quilt/Test").top_hash # Verify manifest is registered by hash. out_path = LOCAL_REGISTRY / ".quilt/packages" / top_hash with open(out_path) as fd: pkg = Package.load(fd) assert test_file.resolve().as_uri() == pkg['foo'].physical_keys[0] # Verify latest points to the new location. named_pointer_path = LOCAL_REGISTRY / ".quilt/named_packages/Quilt/Test/latest" with open(named_pointer_path) as fd: assert fd.read().replace('\n', '') == top_hash # Test unnamed packages. new_pkg = Package() new_pkg = new_pkg.set('bar', test_file_name) top_hash = new_pkg.build("Quilt/Test").top_hash out_path = LOCAL_REGISTRY / ".quilt/packages" / top_hash with open(out_path) as fd: pkg = Package.load(fd) assert test_file.resolve().as_uri() == pkg['bar'].physical_keys[0]
def test_dir_meta(self): test_meta = {'test': 'meta'} pkg = Package() pkg.set('asdf/jkl', LOCAL_MANIFEST) pkg.set('asdf/qwer', LOCAL_MANIFEST) pkg.set('qwer/asdf', LOCAL_MANIFEST) pkg.set('qwer/as/df', LOCAL_MANIFEST) pkg.build('Quilt/Test') assert pkg['asdf'].meta == {} assert pkg.meta == {} assert pkg['qwer']['as'].meta == {} pkg['asdf'].set_meta(test_meta) assert pkg['asdf'].meta == test_meta pkg['qwer']['as'].set_meta(test_meta) assert pkg['qwer']['as'].meta == test_meta pkg.set_meta(test_meta) assert pkg.meta == test_meta dump_path = 'test_meta' with open(dump_path, 'w') as f: pkg.dump(f) with open(dump_path) as f: pkg2 = Package.load(f) assert pkg2['asdf'].meta == test_meta assert pkg2['qwer']['as'].meta == test_meta assert pkg2.meta == test_meta
def test_commit_message_on_push(self): """ Verify commit messages populate correctly on push.""" with patch('botocore.client.BaseClient._make_api_call', new=mock_make_api_call), \ patch('quilt3.Package._materialize') as materialize_mock, \ patch('quilt3.Package._build') as build_mock: with open(REMOTE_MANIFEST) as fd: pkg = Package.load(fd) materialize_mock.return_value = pkg pkg.push('Quilt/test_pkg_name', 's3://test-bucket', message='test_message') build_mock.assert_called_once_with( 'Quilt/test_pkg_name', registry='s3://test-bucket', message='test_message' )
def test_read_manifest(self): """ Verify reading serialized manifest from disk. """ with open(LOCAL_MANIFEST) as fd: pkg = Package.load(fd) out_path = 'new_manifest.jsonl' with open(out_path, 'w') as fd: pkg.dump(fd) # Insepct the jsonl to verify everything is maintained, i.e. # that load/dump results in an equivalent set. # todo: Use load/dump once __eq__ implemented. with open(LOCAL_MANIFEST) as fd: original_set = list(jsonlines.Reader(fd)) with open(out_path) as fd: written_set = list(jsonlines.Reader(fd)) assert len(original_set) == len(written_set) assert sorted(original_set, key=lambda k: k.get('logical_key', 'manifest')) \ == sorted(written_set, key=lambda k: k.get('logical_key', 'manifest'))