Ejemplo n.º 1
0
 def test_get_annotation_missing_annotation(self, tmpdir):
     """Getting an annotation which doesn't exist returns None"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s/annotations" % (base_backup_dir, test_backup_id))
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     assert (annotation_manager.get_annotation(test_backup_id,
                                               "test_annotation") is None)
Ejemplo n.º 2
0
 def test_get_annotation_missing_backup(self, tmpdir):
     """Getting an annotation for a backup which doesn't exist returns None"""
     base_backup_dir = tmpdir.mkdir("base")
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     assert (
         annotation_manager.get_annotation(test_backup_id, "test_annotation") is None
     )
Ejemplo n.º 3
0
 def test_put_annotation_for_missing_backup(self, tmpdir):
     """Tests we can annotate a backup which doesn't exist"""
     base_backup_dir = tmpdir.mkdir("base")
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     annotation_manager.put_annotation(test_backup_id, "test_annotation",
                                       "annotation_value")
     assert (self._get_annotation_from_filesystem(
         base_backup_dir, test_backup_id,
         "test_annotation") == "annotation_value")
Ejemplo n.º 4
0
 def test_get_annotation(self, tmpdir):
     """Tests getting the value of a single annotation"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s/annotations" % (base_backup_dir, test_backup_id))
     self._create_annotation_on_filesystem(base_backup_dir, test_backup_id,
                                           "test_annotation",
                                           "annotation_value")
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     assert (annotation_manager.get_annotation(
         test_backup_id, "test_annotation") == "annotation_value")
Ejemplo n.º 5
0
 def test_delete_is_idempotent(self, tmpdir):
     """Tests a single annotation can be deleted multiple times with the same result"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s/annotations" % (base_backup_dir, test_backup_id))
     self._create_annotation_on_filesystem(base_backup_dir, test_backup_id,
                                           "test_annotation",
                                           "annotation_value")
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     annotation_manager.delete_annotation(test_backup_id, "test_annotation")
     annotation_manager.delete_annotation(test_backup_id, "test_annotation")
Ejemplo n.º 6
0
 def test_put_annotation(self, tmpdir):
     """Tests a single annotation is stored"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s" % (base_backup_dir, test_backup_id))
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     annotation_manager.put_annotation(test_backup_id, "test_annotation",
                                       "annotation_value")
     assert (self._get_annotation_from_filesystem(
         base_backup_dir, test_backup_id,
         "test_annotation") == "annotation_value")
Ejemplo n.º 7
0
 def test_delete_annotation(self, tmpdir):
     """Tests we delete an annotation successfully"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s/annotations" % (base_backup_dir, test_backup_id))
     self._create_annotation_on_filesystem(base_backup_dir, test_backup_id,
                                           "test_annotation",
                                           "annotation_value")
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     annotation_manager.delete_annotation(test_backup_id, "test_annotation")
     assert not os.path.isfile("%s/%s/annotations/test_annotation" %
                               (base_backup_dir, test_backup_id))
     assert not os.path.isfile("%s/%s/annotations" %
                               (base_backup_dir, test_backup_id))
     assert os.path.isdir("%s/%s" % (base_backup_dir, test_backup_id))
Ejemplo n.º 8
0
 def test_put_annotation_is_idempotent(self, tmpdir):
     """Tests a single annotation can be added multiple times with the same result"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s" % (base_backup_dir, test_backup_id))
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     annotation_manager.put_annotation(test_backup_id, "test_annotation",
                                       "annotation_value")
     annotation_manager.put_annotation(test_backup_id, "test_annotation",
                                       "annotation_value")
     assert (self._get_annotation_from_filesystem(
         base_backup_dir, test_backup_id,
         "test_annotation") == "annotation_value")
Ejemplo n.º 9
0
 def test_put_multiple_annotations(self, tmpdir):
     """Tests multiple annotations can be written"""
     base_backup_dir = tmpdir.mkdir("base")
     os.makedirs("%s/%s" % (base_backup_dir, test_backup_id))
     annotation_manager = AnnotationManagerFile(base_backup_dir)
     annotation_manager.put_annotation(test_backup_id, "test_annotation",
                                       "annotation_value")
     annotation_manager.put_annotation(test_backup_id, "test_annotation_2",
                                       "annotation_value_2")
     assert (self._get_annotation_from_filesystem(
         base_backup_dir, test_backup_id,
         "test_annotation") == "annotation_value")
     assert (self._get_annotation_from_filesystem(
         base_backup_dir, test_backup_id,
         "test_annotation_2") == "annotation_value_2")