Skip to content

Commit f555c30

Browse files
authored
Merge pull request #4 from xebialabs-community/deleteBookmark
Adding an automated test for delete bookmark
2 parents 37ae890 + 515fa68 commit f555c30

File tree

5 files changed

+72
-58
lines changed

5 files changed

+72
-58
lines changed

src/main/resources/delphix/DelphixClient.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from delphixpy.web.selfservice import branch
1414

1515
from delphix.lib.DelphixSession import DelphixSession
16+
from delphix.lib.GetReferences import find_bookmark_ref
1617
from delphix.lib.GetReferences import find_obj_name
1718
import delphix.lib.Util as Util
1819

@@ -53,4 +54,12 @@ def delphix_listbookmarks(self, variables):
5354
result.append(key)
5455
print "%s\n" % key
5556

56-
variables['bookmarks'] = result
57+
variables['bookmarks'] = result
58+
59+
def delphix_deletebookmark(self, variables):
60+
path = Util.split_bookmark_path(variables['bookmark_path'])
61+
62+
bookmark_ref = find_bookmark_ref(self.engine, path['template_name'], path['container_name'], path['branch_name'], path['bookmark_name'])
63+
bookmark.delete(self.engine, bookmark_ref)
64+
65+
print "Bookmark '%s' deleted" % variables['bookmark_path']

src/main/resources/delphix/lib/GetReferences.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414

1515
import re
1616

17-
from delphixpy.v1_9_0.web.service import time
18-
from delphixpy.v1_9_0.exceptions import RequestError
19-
from delphixpy.v1_9_0.exceptions import HttpError
20-
from delphixpy.v1_9_0.exceptions import JobError
21-
from delphixpy.v1_9_0.web import repository
22-
from delphixpy.v1_9_0.web import database
23-
from delphixpy.v1_9_0.web import source
24-
from delphixpy.v1_9_0.web import job
25-
from delphixpy.v1_9_0.web import sourceconfig
26-
27-
from delphixpy.v1_9_0.web.jetstream import template
28-
from delphixpy.v1_9_0.web.jetstream import container
29-
from delphixpy.v1_9_0.web.jetstream import branch
30-
from delphixpy.v1_9_0.web.jetstream import bookmark
17+
from delphixpy.web.service import time
18+
from delphixpy.exceptions import RequestError
19+
from delphixpy.exceptions import HttpError
20+
from delphixpy.exceptions import JobError
21+
from delphixpy.web import repository
22+
from delphixpy.web import database
23+
from delphixpy.web import source
24+
from delphixpy.web import job
25+
from delphixpy.web import sourceconfig
26+
27+
from delphixpy.web.selfservice import template
28+
from delphixpy.web.selfservice import container
29+
from delphixpy.web.selfservice import branch
30+
from delphixpy.web.selfservice import bookmark
3131

3232
from DlpxException import DlpxException
3333

src/main/resources/delphix/deleteBookmark.py renamed to src/test/jython/itests/Bookmarks_delete_test.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,19 @@
88
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
99
#
1010

11-
# Deletes a bookmark
12-
#
13-
# :param dlpx_obj: Virtualization Engine session object
14-
# :type dlpx_obj: lib.GetSession.GetSession
15-
# :param bookmark_name: Bookmark to delete
16-
# :type bookmark_name: str
17-
18-
import sys
19-
20-
from delphixpy.web.jetstream import bookmark
21-
from delphixpy import exceptions
2211

23-
from delphix.lib.DelphixSession import DelphixSession
24-
from delphix.lib.GetReferences import find_bookmark_ref
25-
import delphix.lib.Util as Util
2612

27-
engine = DelphixSession.create(server).server_session
13+
import unittest
14+
from itests import DelphixServerCi
15+
from delphix.DelphixClient import DelphixClient
16+
from delphix.lib.DlpxException import DlpxException
2817

29-
path = Util.split_bookmark_path(bookmark_path)
3018

31-
bookmark_ref = find_bookmark_ref(engine, path['template_name'], path['container_name'], path['branch_name'], path['bookmark_name'])
19+
class DeleteBookmark(unittest.TestCase):
3220

33-
try:
34-
bookmark.delete(engine, bookmark_ref)
35-
except exceptions.RequestError as e:
36-
print 'EXCEPTION: [%s] \n' % e.message
37-
sys.exit(1)
3821

39-
print "Bookmark '%s' deleted" % bookmark_path
40-
sys.exit(0)
22+
def test_delete_bookmarks(self):
23+
client = DelphixClient.create_client(DelphixServerCi())
24+
variables = {"bookmark_path": "/something/here/goes/away" }
25+
with self.assertRaises(DlpxException):
26+
client.delphix_deletebookmark(variables)

src/test/jython/itests/Bookmarks_list_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2017 XEBIALABS
2+
# Copyright 2018 XEBIALABS
33
#
44
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55
#

src/test/resources/docker/delphix/main.go

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,47 @@ type DelphixResponse struct {
1717

1818
func main() {
1919
router := mux.NewRouter().StrictSlash(true)
20-
router.HandleFunc("/resources/json/delphix/selfservice/bookmark", ReturnBookmarkResponse).Methods("GET")
2120
router.HandleFunc("/resources/json/delphix/database/{ref_id}/refresh", ReturnDatabaseRefreshResponse).Methods("POST")
22-
router.HandleFunc("/resources/json/delphix/session", ReturnSessionResponse).Methods("POST")
21+
2322
router.HandleFunc("/resources/json/delphix/login", ReturnLoginResponse).Methods("POST")
23+
24+
router.HandleFunc("/resources/json/delphix/selfservice/bookmark", ReturnBookmarkResponse).Methods("GET")
25+
router.HandleFunc("/resources/json/delphix/selfservice/template", ReturnTemplateResponse).Methods("GET")
26+
27+
28+
router.HandleFunc("/resources/json/delphix/session", ReturnSessionResponse).Methods("POST")
2429

2530
log.Fatal(http.ListenAndServe(":8080", router))
2631
}
2732

33+
// ReturnDatabaseRefreshResponse sends a dummy response back
34+
func ReturnDatabaseRefreshResponse(res http.ResponseWriter, req *http.Request) {
35+
res.Header().Set("Content-Type", "application/json")
36+
b := json.RawMessage(`{
37+
"type":"OKResult",
38+
"status":"OK",
39+
"result": "",
40+
"job":null,
41+
"action":null
42+
}`)
43+
res.WriteHeader(http.StatusOK)
44+
fmt.Fprint(res, string(b))
45+
}
46+
47+
// ReturnLoginResponse sends a dummy response back
48+
func ReturnLoginResponse(res http.ResponseWriter, req *http.Request) {
49+
res.Header().Set("Content-Type", "application/json")
50+
b := json.RawMessage(`{
51+
"status":"OK",
52+
"type": "OKResult",
53+
"result":"USER-2",
54+
"job":null,
55+
"action":null
56+
}`)
57+
res.WriteHeader(http.StatusOK)
58+
fmt.Fprint(res, string(b))
59+
}
60+
2861
// ReturnBookmarkResponse sends a dummy response back
2962
func ReturnBookmarkResponse(res http.ResponseWriter, req *http.Request) {
3063
res.Header().Set("Content-Type", "application/json")
@@ -39,8 +72,8 @@ func ReturnBookmarkResponse(res http.ResponseWriter, req *http.Request) {
3972
fmt.Fprint(res, string(b))
4073
}
4174

42-
// ReturnDatabaseRefreshResponse sends a dummy response back
43-
func ReturnDatabaseRefreshResponse(res http.ResponseWriter, req *http.Request) {
75+
// ReturnTemplateResponse sends a dummy response back
76+
func ReturnTemplateResponse(res http.ResponseWriter, req *http.Request) {
4477
res.Header().Set("Content-Type", "application/json")
4578
b := json.RawMessage(`{
4679
"type":"OKResult",
@@ -75,17 +108,3 @@ func ReturnSessionResponse(res http.ResponseWriter, req *http.Request) {
75108
res.WriteHeader(http.StatusOK)
76109
fmt.Fprint(res, string(b))
77110
}
78-
79-
// ReturnLoginResponse sends a dummy response back
80-
func ReturnLoginResponse(res http.ResponseWriter, req *http.Request) {
81-
res.Header().Set("Content-Type", "application/json")
82-
b := json.RawMessage(`{
83-
"status":"OK",
84-
"type": "OKResult",
85-
"result":"USER-2",
86-
"job":null,
87-
"action":null
88-
}`)
89-
res.WriteHeader(http.StatusOK)
90-
fmt.Fprint(res, string(b))
91-
}

0 commit comments

Comments
 (0)