author | Shawn Walker <srw@sun.com> |
Thu, 23 Jul 2009 14:17:08 -0500 | |
changeset 1254 | 28871b08d49c |
parent 1252 | 3b1b69011fcf |
child 1507 | b956ea23d3a6 |
permissions | -rw-r--r-- |
1252
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.4 |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
2 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
4 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
8 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
13 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
19 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
21 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
22 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
23 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
24 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
25 |
# Use is subject to license terms. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
26 |
# |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
27 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
28 |
import copy |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
29 |
import errno |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
30 |
import os |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
31 |
import pkg.client.api_errors as api_errors |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
32 |
import pkg.client.publisher as publisher |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
33 |
import shutil |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
34 |
import sys |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
35 |
import tempfile |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
36 |
import unittest |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
37 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
38 |
# Set the path so that modules above can be found. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
39 |
path_to_parent = os.path.join(os.path.dirname(__file__), "..") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
40 |
sys.path.insert(0, path_to_parent) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
41 |
import pkg5unittest |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
42 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
43 |
class TestPublisher(pkg5unittest.Pkg5TestCase): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
44 |
"""Class to test the functionality of the pkg.client.publisher module. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
45 |
""" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
46 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
47 |
misc_files = [ "test.cert", "test.key", "test2.cert", "test2.key" ] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
48 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
49 |
def setUp(self): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
50 |
self.pid = os.getpid() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
51 |
self.pwd = os.getcwd() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
52 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
53 |
self.__test_prefix = os.path.join(tempfile.gettempdir(), |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
54 |
"ips.test.%d" % self.pid) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
55 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
56 |
try: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
57 |
os.makedirs(self.__test_prefix, 0755) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
58 |
except OSError, e: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
59 |
if e.errno != errno.EEXIST: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
60 |
raise e |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
61 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
62 |
for p in self.misc_files: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
63 |
fpath = os.path.join(self.get_test_prefix(), p) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
64 |
f = open(fpath, "wb") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
65 |
# Write the name of the file into the file, so that |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
66 |
# all files have differing contents. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
67 |
f.write(fpath) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
68 |
f.close() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
69 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
70 |
def tearDown(self): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
71 |
shutil.rmtree(self.get_test_prefix()) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
72 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
73 |
def get_test_prefix(self): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
74 |
return self.__test_prefix |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
75 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
76 |
def test_01_repository_uri(self): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
77 |
"""Verify that a RepositoryURI object can be created, copied, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
78 |
modified, and used as expected.""" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
79 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
80 |
nsfile = os.path.join(self.get_test_prefix(), "nosuchfile") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
81 |
tcert = os.path.join(self.get_test_prefix(), "test.cert") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
82 |
tkey = os.path.join(self.get_test_prefix(), "test.key") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
83 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
84 |
uprops = { |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
85 |
"priority": 1, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
86 |
"ssl_cert": tcert, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
87 |
"ssl_key": tkey, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
88 |
"trailing_slash": False, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
89 |
} |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
90 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
91 |
# Check that all properties can be set at construction time. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
92 |
uobj = publisher.RepositoryURI("https://example.com", **uprops) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
93 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
94 |
# Verify that all properties provided at construction time were |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
95 |
# set as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
96 |
self.assertEqual(uobj.uri, "https://example.com") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
97 |
for p in uprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
98 |
self.assertEqual(uprops[p], getattr(uobj, p)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
99 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
100 |
# Verify that scheme matches provided URI. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
101 |
self.assertEqual(uobj.scheme, "https") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
102 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
103 |
# Verify that a copy matches its original. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
104 |
cuobj = copy.copy(uobj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
105 |
self.assertEqual(uobj.uri, cuobj.uri) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
106 |
for p in uprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
107 |
self.assertEqual(getattr(uobj, p), getattr(cuobj, p)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
108 |
cuobj = None |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
109 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
110 |
# Verify that setting invalid property values raises the |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
111 |
# expected exception. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
112 |
self.assertRaises(api_errors.BadRepositoryURI, setattr, uobj, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
113 |
"uri", None) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
114 |
self.assertRaises(api_errors.UnsupportedRepositoryURI, setattr, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
115 |
uobj, "uri", ":/notvalid") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
116 |
self.assertRaises(api_errors.BadRepositoryURIPriority, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
117 |
setattr, uobj, "priority", "foo") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
118 |
self.assertRaises(api_errors.BadRepositoryAttributeValue, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
119 |
setattr, uobj, "ssl_cert", -1) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
120 |
self.assertRaises(api_errors.NoSuchCertificate, setattr, uobj, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
121 |
"ssl_cert", nsfile) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
122 |
self.assertRaises(api_errors.BadRepositoryAttributeValue, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
123 |
setattr, uobj, "ssl_key", -1) |
1254
28871b08d49c
8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents:
1252
diff
changeset
|
124 |
self.assertRaises(api_errors.NoSuchKey, setattr, uobj, |
1252
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
125 |
"ssl_key", nsfile) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
126 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
127 |
# Verify that changing the URI scheme will null properties that |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
128 |
# no longer apply. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
129 |
uobj.uri = "http://example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
130 |
self.assertEqual(uobj.ssl_cert, None) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
131 |
self.assertEqual(uobj.ssl_key, None) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
132 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
133 |
# Verify that scheme matches provided URI. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
134 |
self.assertEqual(uobj.scheme, "http") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
135 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
136 |
# Verify that attempting to set properties not valid for the |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
137 |
# current URI scheme raises the expected exception. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
138 |
self.assertRaises(api_errors.UnsupportedRepositoryURIAttribute, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
139 |
setattr, uobj, "ssl_cert", tcert) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
140 |
self.assertRaises(api_errors.UnsupportedRepositoryURIAttribute, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
141 |
setattr, uobj, "ssl_key", tkey) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
142 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
143 |
# Verify that individual properties can be set. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
144 |
uobj = publisher.RepositoryURI("https://example.com/") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
145 |
for p in uprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
146 |
setattr(uobj, p, uprops[p]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
147 |
self.assertEqual(getattr(uobj, p), uprops[p]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
148 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
149 |
# Finally, verify all properties (except URI and trailing_slash) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
150 |
# can be set to None. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
151 |
for p in ("priority", "ssl_cert", "ssl_key"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
152 |
setattr(uobj, p, None) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
153 |
self.assertEqual(getattr(uobj, p), None) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
154 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
155 |
def test_02_repository(self): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
156 |
"""Verify that a Repository object can be created, copied, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
157 |
modified, and used as expected.""" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
158 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
159 |
tcert = os.path.join(self.get_test_prefix(), "test.cert") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
160 |
tkey = os.path.join(self.get_test_prefix(), "test.key") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
161 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
162 |
t2cert = os.path.join(self.get_test_prefix(), "test2.cert") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
163 |
t2key = os.path.join(self.get_test_prefix(), "test2.key") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
164 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
165 |
rprops = { |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
166 |
"collection_type": publisher.REPO_CTYPE_SUPPLEMENTAL, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
167 |
"description": "Provides only the best BobCat packages!", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
168 |
"legal_uris": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
169 |
"http://legal1.example.com", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
170 |
"http://legal2.example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
171 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
172 |
"mirrors": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
173 |
"http://mirror1.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
174 |
"http://mirror2.example.com/" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
175 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
176 |
"name": "BobCat Repository", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
177 |
"origins": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
178 |
"http://origin1.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
179 |
"http://origin2.example.com/" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
180 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
181 |
"refresh_seconds": 70000, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
182 |
"registered": True, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
183 |
"registration_uri": "http://register.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
184 |
"related_uris": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
185 |
"http://related1.example.com", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
186 |
"http://related2.example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
187 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
188 |
"sort_policy": publisher.URI_SORT_PRIORITY, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
189 |
} |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
190 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
191 |
# Check that all properties can be set at construction time. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
192 |
robj = publisher.Repository(**rprops) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
193 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
194 |
# Verify that all properties provided at construction time were |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
195 |
# set as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
196 |
for p in rprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
197 |
self.assertEqual(rprops[p], getattr(robj, p)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
198 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
199 |
# Verify that a copy matches its original. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
200 |
crobj = copy.copy(robj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
201 |
for p in rprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
202 |
self.assertEqual(getattr(robj, p), getattr(crobj, p)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
203 |
crobj = None |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
204 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
205 |
# New set of rprops for testing (all the URI use https so that |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
206 |
# setting ssl_key and ssl_cert can be tested). |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
207 |
rprops = { |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
208 |
"collection_type": publisher.REPO_CTYPE_SUPPLEMENTAL, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
209 |
"description": "Provides only the best BobCat packages!", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
210 |
"legal_uris": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
211 |
"https://legal1.example.com", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
212 |
"https://legal2.example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
213 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
214 |
"mirrors": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
215 |
"https://mirror1.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
216 |
"https://mirror2.example.com/" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
217 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
218 |
"name": "BobCat Repository", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
219 |
"origins": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
220 |
"https://origin1.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
221 |
"https://origin2.example.com/" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
222 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
223 |
"refresh_seconds": 70000, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
224 |
"registered": True, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
225 |
"registration_uri": "https://register.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
226 |
"related_uris": [ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
227 |
"https://related1.example.com", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
228 |
"https://related2.example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
229 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
230 |
"sort_policy": publisher.URI_SORT_PRIORITY, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
231 |
} |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
232 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
233 |
# Verify that individual properties can be set. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
234 |
robj = publisher.Repository() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
235 |
for p in rprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
236 |
setattr(robj, p, rprops[p]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
237 |
self.assertEqual(getattr(robj, p), rprops[p]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
238 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
239 |
# Verify that setting invalid property values raises the |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
240 |
# expected exception. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
241 |
self.assertRaises(api_errors.BadRepositoryCollectionType, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
242 |
setattr, robj, "collection_type", -1) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
243 |
self.assertRaises(api_errors.BadRepositoryAttributeValue, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
244 |
setattr, robj, "refresh_seconds", -1) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
245 |
self.assertRaises(api_errors.BadRepositoryURISortPolicy, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
246 |
setattr, robj, "sort_policy", -1) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
247 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
248 |
# Verify that add functions work as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
249 |
robj = publisher.Repository() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
250 |
for utype in ("legal_uri", "mirror", "origin", "related_uri"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
251 |
prop = utype + "s" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
252 |
for u in rprops[prop]: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
253 |
method = getattr(robj, "add_%s" % utype) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
254 |
method(u, priority=1, ssl_cert=tcert, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
255 |
ssl_key=tkey) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
256 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
257 |
# Verify that has and get functions work as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
258 |
for utype in ("mirror", "origin"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
259 |
prop = utype + "s" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
260 |
for u in rprops[prop]: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
261 |
method = getattr(robj, "has_%s" % utype) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
262 |
self.assertTrue(method(u)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
263 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
264 |
method = getattr(robj, "get_%s" % utype) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
265 |
cu = publisher.RepositoryURI(u, priority=1, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
266 |
ssl_cert=tcert, ssl_key=tkey, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
267 |
trailing_slash=True) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
268 |
ou = method(u) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
269 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
270 |
# This verifies that the expected URI object is |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
271 |
# returned and that all of the properties match |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
272 |
# exactly as they were added. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
273 |
for uprop in ("uri", "priority", "ssl_cert", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
274 |
"ssl_key", "trailing_slash"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
275 |
self.assertEqual(getattr(cu, uprop), |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
276 |
getattr(ou, uprop)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
277 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
278 |
# Verify that remove functions work as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
279 |
for utype in ("legal_uri", "mirror", "origin", "related_uri"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
280 |
prop = utype + "s" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
281 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
282 |
# Remove only the first URI for each property. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
283 |
u = rprops[prop][0] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
284 |
method = getattr(robj, "remove_%s" % utype) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
285 |
method(u) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
286 |
self.assertTrue(u not in getattr(robj, prop)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
287 |
self.assertEqual(len(getattr(robj, prop)), 1) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
288 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
289 |
# Verify that update functions work as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
290 |
for utype in ("mirror", "origin"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
291 |
prop = utype + "s" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
292 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
293 |
# Update only the last entry for each property. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
294 |
u = rprops[prop][-1] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
295 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
296 |
method = getattr(robj, "update_%s" % utype) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
297 |
method(u, priority=2, ssl_cert=t2cert, ssl_key=t2key) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
298 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
299 |
method = getattr(robj, "get_%s" % utype) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
300 |
ou = method(u) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
301 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
302 |
# This verifies that the expected URI object is |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
303 |
# returned and that all of the properties match |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
304 |
# exactly as specified to the update method. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
305 |
cu = publisher.RepositoryURI(u, priority=2, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
306 |
ssl_cert=t2cert, ssl_key=t2key) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
307 |
for uprop in ("uri", "priority", "ssl_cert", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
308 |
"ssl_key", "trailing_slash"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
309 |
self.assertEqual(getattr(cu, uprop), |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
310 |
getattr(ou, uprop)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
311 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
312 |
# Verify that reset functions work as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
313 |
for prop in ("mirrors", "origins"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
314 |
method = getattr(robj, "reset_%s" % prop) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
315 |
method() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
316 |
self.assertEqual(getattr(robj, prop), []) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
317 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
318 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
319 |
def test_03_publisher(self): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
320 |
"""Verify that a Repository object can be created, copied, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
321 |
modified, and used as expected.""" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
322 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
323 |
robj = publisher.Repository( |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
324 |
collection_type=publisher.REPO_CTYPE_SUPPLEMENTAL, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
325 |
description="Provides only the best BobCat packages!", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
326 |
legal_uris=[ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
327 |
"http://legal1.example.com", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
328 |
"http://legal2.example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
329 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
330 |
mirrors=[ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
331 |
"http://mirror1.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
332 |
"http://mirror2.example.com/" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
333 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
334 |
name="First Repository", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
335 |
origins=[ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
336 |
"http://origin1.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
337 |
"http://origin2.example.com/" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
338 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
339 |
refresh_seconds=70000, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
340 |
registered=True, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
341 |
registration_uri="http://register.example.com/", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
342 |
related_uris=[ |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
343 |
"http://related1.example.com", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
344 |
"http://related2.example.com" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
345 |
], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
346 |
sort_policy=publisher.URI_SORT_PRIORITY, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
347 |
) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
348 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
349 |
r2obj = copy.copy(robj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
350 |
r2obj.origins = ["http://origin3.example.com"] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
351 |
r2obj.name = "Second Repository" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
352 |
r2obj.reset_mirrors() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
353 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
354 |
pprops = { |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
355 |
"alias": "cat", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
356 |
"client_uuid": "2c6a8ff8-20e5-11de-a818-001fd0979039", |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
357 |
"disabled": True, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
358 |
"meta_root": os.path.join(self.get_test_prefix(), "bobcat"), |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
359 |
"repositories": [robj, r2obj], |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
360 |
"selected_repository": r2obj, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
361 |
} |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
362 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
363 |
# Check that all properties can be set at construction time. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
364 |
pobj = publisher.Publisher("bobcat", **pprops) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
365 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
366 |
# Verify that all properties provided at construction time were |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
367 |
# set as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
368 |
for p in pprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
369 |
self.assertEqual(pprops[p], getattr(pobj, p)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
370 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
371 |
# Verify that a copy matches its original. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
372 |
cpobj = copy.copy(pobj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
373 |
for p in pprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
374 |
if p in ("repositories", "selected_repository"): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
375 |
# These attributes can't be directly compared. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
376 |
continue |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
377 |
self.assertEqual(getattr(pobj, p), getattr(cpobj, p)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
378 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
379 |
# Assume that if the origins match, we have the right selected |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
380 |
# repository. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
381 |
self.assertEqual(cpobj.selected_repository.origins, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
382 |
r2obj.origins) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
383 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
384 |
# Compare all of the repository objects individually. Assume |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
385 |
# that if the source_object_id matches, that the copy happened |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
386 |
# correctly. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
387 |
for i in range(0, len(pobj.repositories)): |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
388 |
srepo = pobj.repositories[i] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
389 |
crepo = cpobj.repositories[i] |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
390 |
self.assertEqual(id(srepo), crepo._source_object_id) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
391 |
cpobj = None |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
392 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
393 |
# Verify that individual properties can be set. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
394 |
pobj = publisher.Publisher("tomcat") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
395 |
pobj.prefix = "bobcat" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
396 |
self.assertEqual(pobj.prefix, "bobcat") |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
397 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
398 |
for p in pprops: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
399 |
if p == "repositories": |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
400 |
for r in pprops[p]: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
401 |
pobj.add_repository(r) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
402 |
else: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
403 |
setattr(pobj, p, pprops[p]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
404 |
self.assertEqual(getattr(pobj, p), pprops[p]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
405 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
406 |
pobj.selected_repository = robj |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
407 |
self.assertEqual(pobj.selected_repository, robj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
408 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
409 |
# An invalid value shouldn't be allowed. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
410 |
self.assertRaises(api_errors.UnknownRepository, setattr, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
411 |
pobj, "selected_repository", -1) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
412 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
413 |
# A repository object not already in the list of repositories |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
414 |
# shouldn't be allowed. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
415 |
self.assertRaises(api_errors.UnknownRepository, setattr, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
416 |
pobj, "selected_repository", publisher.Repository()) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
417 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
418 |
# Verify that management methods work as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
419 |
pobj.set_selected_repository(origin=r2obj.origins[-1]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
420 |
self.assertEqual(pobj.selected_repository, r2obj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
421 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
422 |
pobj.set_selected_repository(name=robj.name) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
423 |
self.assertEqual(pobj.selected_repository, robj) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
424 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
425 |
pobj.reset_client_uuid() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
426 |
self.assertNotEqual(pobj.client_uuid, None) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
427 |
self.assertNotEqual(pobj.client_uuid, pprops["client_uuid"]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
428 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
429 |
pobj.create_meta_root() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
430 |
self.assertTrue(os.path.exists(pobj.meta_root)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
431 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
432 |
pobj.remove_meta_root() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
433 |
self.assertFalse(os.path.exists(pobj.meta_root)) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
434 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
435 |
# Verify that get and remove works as expected. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
436 |
for r in pprops["repositories"]: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
437 |
gr = pobj.get_repository(name=r.name) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
438 |
self.assertEqual(r, gr) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
439 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
440 |
gr = pobj.get_repository(origin=r.origins[-1]) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
441 |
self.assertEqual(r, gr) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
442 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
443 |
if r == pobj.selected_repository: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
444 |
# Attempting to remove the selected repository |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
445 |
# should raise an exception. |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
446 |
ex = api_errors.SelectedRepositoryRemoval |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
447 |
self.assertRaises(ex, pobj.remove_repository, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
448 |
name=r.name) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
449 |
else: |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
450 |
pobj.remove_repository(name=r.name) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
451 |
self.assertRaises(api_errors.UnknownRepository, |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
452 |
pobj.get_repository, name=r.name) |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
453 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
454 |
|
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
455 |
if __name__ == "__main__": |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
456 |
unittest.main() |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
diff
changeset
|
457 |