def FromInstallState(install_state): """Loads a snapshot from the local installation state. This creates a snapshot that may not have actually existed at any point in time. It does, however, exactly reflect the current state of your local SDK. Args: install_state: install_state.InstallState, The InstallState object to load from. Returns: A ComponentSnapshot object. """ installed = install_state.InstalledComponents() components = [ manifest.ComponentDefinition() for manifest in installed.values() ] sdk_definition = schemas.SDKDefinition(revision=-1, schema_version=None, release_notes_url=None, version=None, gcloud_rel_path=None, post_processing_command=None, components=components, notifications={}) return ComponentSnapshot(sdk_definition)
def testUnknownDependency(self): a = self.CreateFakeComponent('a', ['b']) snapshot = snapshots.ComponentSnapshot( schemas.SDKDefinition( revision=1, schema_version=None, release_notes_url=None, version=None, gcloud_rel_path=None, post_processing_command=None, components=[a], notifications={})) # Invalid dependency should be removed self.assertEqual(set(['a']), snapshot.DependencyClosureForComponents(['a']))
def testBadSchemaVersion(self): sdk_def = schemas.SDKDefinition( revision=1, schema_version=schemas.SchemaVersion( config.INSTALLATION_CONFIG.snapshot_schema_version + 1, no_update=False, message='', url=''), release_notes_url=None, version=None, gcloud_rel_path=None, post_processing_command=None, components=[], notifications={}) with self.assertRaises(snapshots.IncompatibleSchemaVersionError): snapshots.ComponentSnapshot._FromDictionary( (sdk_def.ToDictionary(), None))