Added OVH snapshot tests
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e4f124e2 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e4f124e2 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e4f124e2 Branch: refs/heads/trunk Commit: e4f124e27194606220462ef4968f8b6885c2ebd7 Parents: 4f7bc9c Author: ZuluPro <montheanth...@hotmail.com> Authored: Sun Oct 9 13:23:09 2016 -0400 Committer: ZuluPro <montheanth...@hotmail.com> Committed: Sun Oct 9 22:22:31 2016 -0400 ---------------------------------------------------------------------- .../fixtures/ovh/volume_snapshot_get.json | 22 ++++++++++++ .../ovh/volume_snapshot_get_details.json | 10 ++++++ libcloud/test/compute/test_ovh.py | 38 ++++++++++++++++++++ 3 files changed, 70 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e4f124e2/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json new file mode 100644 index 0000000..a96446a --- /dev/null +++ b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get.json @@ -0,0 +1,22 @@ +[ + { + "volumeId": "foo", + "status": "available", + "region": "GRA1", + "name": "", + "description": "", + "size": 10, + "creationDate": "2016-10-10T17:33:02Z", + "id": "foo-snap" + }, + { + "volumeId": "bar", + "status": "available", + "region": "GRA1", + "name": "", + "description": "", + "size": 10, + "creationDate": "2016-10-09T17:33:02Z", + "id": "bar-snap" + } +] http://git-wip-us.apache.org/repos/asf/libcloud/blob/e4f124e2/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json new file mode 100644 index 0000000..63eb4d6 --- /dev/null +++ b/libcloud/test/compute/fixtures/ovh/volume_snapshot_get_details.json @@ -0,0 +1,10 @@ +{ + "volumeId": "foo", + "status": "available", + "region": "GRA1", + "name": "", + "description": "", + "size": 10, + "creationDate": "2016-10-10T17:33:02Z", + "id": "foo-snap" +} http://git-wip-us.apache.org/repos/asf/libcloud/blob/e4f124e2/libcloud/test/compute/test_ovh.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_ovh.py b/libcloud/test/compute/test_ovh.py index 8f30687..f434f7a 100644 --- a/libcloud/test/compute/test_ovh.py +++ b/libcloud/test/compute/test_ovh.py @@ -107,6 +107,25 @@ class OvhMockHttp(BaseOvhMockHttp): body = self.fixtures.load('volume_get_detail.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _json_1_0_cloud_project_project_id_volume_snapshot_region_SBG_1_get(self, method, url, body, headers): + body = self.fixtures.load('volume_snapshot_get.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _json_1_0_cloud_project_project_id_volume_snapshot_get(self, method, url, body, headers): + body = self.fixtures.load('volume_snapshot_get.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _json_1_0_cloud_project_project_id_volume_snapshot_foo_get(self, method, url, body, headers): + body = self.fixtures.load('volume_snapshot_get_details.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _json_1_0_cloud_project_project_id_volume_snapshot_foo_snap_delete(self, method, url, body, headers): + return (httplib.OK, None, {}, httplib.responses[httplib.OK]) + + def _json_1_0_cloud_project_project_id_volume_foo_snapshot__post(self, method, url, body, headers): + body = self.fixtures.load('volume_snapshot_get_details.json') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + @patch('libcloud.common.ovh.OvhConnection._timedelta', 42) class OvhTests(unittest.TestCase): @@ -201,5 +220,24 @@ class OvhTests(unittest.TestCase): response = self.driver.detach_volume(ex_node=node, volume=volume) self.assertTrue(response) + def test_ex_list_snapshots(self): + self.driver.ex_list_snapshots() + + def test_ex_get_volume_snapshot(self): + self.driver.ex_get_volume_snapshot('foo') + + def test_list_volume_snapshots(self): + volume = self.driver.ex_get_volume('foo') + self.driver.list_volume_snapshots(volume) + + def test_create_volume_snapshot(self): + volume = self.driver.ex_get_volume('foo') + self.driver.create_volume_snapshot(volume) + + def test_destroy_volume_snapshot(self): + snapshot = self.driver.ex_get_volume_snapshot('foo') + result = self.driver.destroy_volume_snapshot(snapshot) + self.assertTrue(result) + if __name__ == '__main__': sys.exit(unittest.main())