@@ -552,3 +552,56 @@ def create_backups(attrs=None, count=2):
552552 backups .append (backup )
553553
554554 return backups
555+
556+
557+ class FakeSnapshot (object ):
558+ """Fake one or more snapshot."""
559+
560+ @staticmethod
561+ def create_one_snapshot (attrs = None ):
562+ """Create a fake snapshot.
563+
564+ :param Dictionary attrs:
565+ A dictionary with all attributes
566+ :return:
567+ A FakeResource object with id, name, description, etc.
568+ """
569+ attrs = attrs or {}
570+
571+ # Set default attributes.
572+ snapshot_info = {
573+ "id" : 'snapshot-id-' + uuid .uuid4 ().hex ,
574+ "name" : 'snapshot-name-' + uuid .uuid4 ().hex ,
575+ "description" : 'snapshot-description-' + uuid .uuid4 ().hex ,
576+ "size" : 10 ,
577+ "status" : "available" ,
578+ "metadata" : {"foo" : "bar" },
579+ "created_at" : "2015-06-03T18:49:19.000000" ,
580+ "volume_id" : 'vloume-id-' + uuid .uuid4 ().hex ,
581+ }
582+
583+ # Overwrite default attributes.
584+ snapshot_info .update (attrs )
585+
586+ snapshot = fakes .FakeResource (
587+ info = copy .deepcopy (snapshot_info ),
588+ loaded = True )
589+ return snapshot
590+
591+ @staticmethod
592+ def create_snapshots (attrs = None , count = 2 ):
593+ """Create multiple fake snapshots.
594+
595+ :param Dictionary attrs:
596+ A dictionary with all attributes
597+ :param int count:
598+ The number of snapshots to fake
599+ :return:
600+ A list of FakeResource objects faking the snapshots
601+ """
602+ snapshots = []
603+ for i in range (0 , count ):
604+ snapshot = FakeSnapshot .create_one_snapshot (attrs )
605+ snapshots .append (snapshot )
606+
607+ return snapshots
0 commit comments