File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 29
29
from gcloud .connection import get_scoped_connection
30
30
from gcloud .pubsub import _implicit_environ
31
31
from gcloud .pubsub ._implicit_environ import get_default_connection
32
+ from gcloud .pubsub .api import list_topics
32
33
from gcloud .pubsub .connection import Connection
33
34
34
35
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ import time
16
+
15
17
import unittest2
16
18
17
19
from gcloud import _helpers
@@ -40,3 +42,23 @@ def test_create_topic(self):
40
42
self .to_delete .append (topic )
41
43
self .assertTrue (topic .exists ())
42
44
self .assertEqual (topic .name , new_topic_name )
45
+
46
+ def test_list_topics (self ):
47
+ topics_to_create = [
48
+ 'new%d' % (1000 * time .time (),),
49
+ 'newer%d' % (1000 * time .time (),),
50
+ 'newest%d' % (1000 * time .time (),),
51
+ ]
52
+ created_topics = []
53
+ for topic_name in topics_to_create :
54
+ topic = Topic (topic_name )
55
+ topic .create ()
56
+ self .to_delete .append (topic )
57
+
58
+ # Retrieve the topics.
59
+ all_topics , _ = pubsub .list_topics ()
60
+ project_id = pubsub .get_default_project ()
61
+ created_topics = [topic for topic in all_topics
62
+ if topic .name in topics_to_create and
63
+ topic .project == project_id ]
64
+ self .assertEqual (len (created_topics ), len (topics_to_create ))
You can’t perform that action at this time.
0 commit comments