示例#1
0
    def test_policy(self, mock):
        mock.get(mocked_url("datastorage/find"),
                 text=mock_datastorage(self.storage_id, self.name, self.path, self.type,
                                                 mock_storage_policy(self.backup_duration, self.lts_duration,
                                                                     self.sts_duration, self.versioning)))
        mock.post(mocked_url("datastorage/policy"),
                  text=mock_datastorage(self.storage_id, self.name, self.path, self.type,
                                        mock_storage_policy(self.backup_duration, self.lts_duration,
                                                            self.sts_duration, self.versioning)))

        actual = DataStorage.policy(self.name, self.sts_duration, self.lts_duration, self.backup_duration,
                                    self.versioning)

        expected = build_storage_model(identifier=self.storage_id, name=self.name, path=self.path,
                                       storage_type=self.type,
                                       policy=build_storage_policy(self.backup_duration,
                                                                   self.lts_duration,
                                                                   self.sts_duration,
                                                                   self.versioning))

        assert_storages(actual, expected)
 def policy(cls, storage_name, sts_duration, lts_duration, backup_duration, versioning):
     try:
         DataStorage.policy(storage_name, sts_duration, lts_duration, backup_duration, versioning)
     except (ConfigNotFoundError, requests.exceptions.RequestException, RuntimeError, ValueError) as error:
         click.echo(str(error), err=True)
         sys.exit(1)