2020
2121
2222class TestCase (base .TestCase ):
23- def setUp (self ):
24- super (TestCase , self ).setUp ()
25- self .acl_list = list ()
2623
27- def tearDown ( self ):
28- for acl_id in self . acl_list :
29- self . consul . acl . destroy ( acl_id )
24+ @ staticmethod
25+ def uuidv4 () :
26+ return str ( uuid . uuid4 () )
3027
3128 def test_bootstrap_success (self ):
32- expectation = str ( uuid . uuid4 () )
29+ expectation = self . uuidv4 ( )
3330
3431 @httmock .all_requests
3532 def response_content (_url_unused , request ):
@@ -46,97 +43,75 @@ def test_bootstrap_raises(self):
4643 self .consul .acl .bootstrap ()
4744
4845 def test_clone_bad_acl_id (self ):
49- acl_id = str (uuid .uuid4 ())
5046 with self .assertRaises (consulate .Forbidden ):
51- self .forbidden_consul .acl .clone (acl_id )
47+ self .consul .acl .clone (self . uuidv4 () )
5248
53- @base .generate_key
54- def test_clone_forbidden (self , acl_id ):
49+ def test_clone_forbidden (self ):
5550 with self .assertRaises (consulate .Forbidden ):
56- self .forbidden_consul .acl .clone (acl_id )
51+ self .forbidden_consul .acl .clone (self . uuidv4 () )
5752
58- @base .generate_key
59- def test_create_and_destroy (self , acl_id ):
60- acl_id = self .consul .acl .create (acl_id )
61- self .acl_list .append (acl_id )
53+ def test_create_and_destroy (self ):
54+ acl_id = self .consul .acl .create (self .uuidv4 ())
6255 self .assertTrue (self .consul .acl .destroy (acl_id ))
6356
64- @base .generate_key
65- def test_create_with_rules (self , acl_id ):
66- acl_id = self .consul .acl .create (acl_id , rules = ACL_RULES )
67- self .acl_list .append (acl_id )
57+ def test_create_with_rules (self ):
58+ acl_id = self .consul .acl .create (self .uuidv4 (), rules = ACL_RULES )
6859 value = self .consul .acl .info (acl_id )
6960 self .assertEqual (value ['Rules' ], ACL_RULES )
7061
71- @base .generate_key
72- def test_create_and_info (self , acl_id ):
73- acl_id = self .consul .acl .create (acl_id )
74- self .acl_list .append (acl_id )
62+ def test_create_and_info (self ):
63+ acl_id = self .consul .acl .create (self .uuidv4 ())
7564 self .assertIsNotNone (acl_id )
7665 data = self .consul .acl .info (acl_id )
7766 self .assertIsNotNone (data )
7867 self .assertEqual (acl_id , data .get ('ID' ))
7968
80- @base .generate_key
81- def test_create_and_list (self , acl_id ):
82- acl_id = self .consul .acl .create (acl_id )
83- self .acl_list .append (acl_id )
69+ def test_create_and_list (self ):
70+ acl_id = self .consul .acl .create (self .uuidv4 ())
8471 data = self .consul .acl .list ()
8572 self .assertIn (acl_id , [r .get ('ID' ) for r in data ])
8673
87- @base .generate_key
88- def test_create_and_clone (self , acl_id ):
89- acl_id = self .consul .acl .create (acl_id )
90- self .acl_list .append (acl_id )
74+ def test_create_and_clone (self ):
75+ acl_id = self .consul .acl .create (self .uuidv4 ())
9176 clone_id = self .consul .acl .clone (acl_id )
92- self .acl_list .append (clone_id )
9377 data = self .consul .acl .list ()
9478 self .assertIn (clone_id , [r .get ('ID' ) for r in data ])
9579
96- @base .generate_key
97- def test_create_and_update (self , acl_id ):
98- acl_id = self .consul .acl .create (acl_id )
99- self .acl_list .append (acl_id )
80+ def test_create_and_update (self ):
81+ acl_id = self .consul .acl .create (self .uuidv4 ())
10082 self .consul .acl .update (acl_id , 'Foo' )
10183 data = self .consul .acl .list ()
10284 self .assertIn ('Foo' , [r .get ('Name' ) for r in data ])
10385 self .assertIn (acl_id , [r .get ('ID' ) for r in data ])
10486
105- @base .generate_key
106- def test_create_forbidden (self , acl_id ):
87+ def test_create_forbidden (self ):
10788 with self .assertRaises (consulate .Forbidden ):
108- self .forbidden_consul .acl .create (acl_id )
89+ self .forbidden_consul .acl .create (self . uuidv4 () )
10990
110- @base .generate_key
111- def test_destroy_forbidden (self , acl_id ):
91+ def test_destroy_forbidden (self ):
11292 with self .assertRaises (consulate .Forbidden ):
113- self .forbidden_consul .acl .destroy (acl_id )
93+ self .forbidden_consul .acl .destroy (self . uuidv4 () )
11494
11595 def test_info_acl_id_not_found (self ):
116- acl_id = str (uuid .uuid4 ())
11796 with self .assertRaises (consulate .NotFound ):
118- self .forbidden_consul .acl .info (acl_id )
97+ self .forbidden_consul .acl .info (self . uuidv4 () )
11998
12099 def test_replication (self ):
121100 result = self .forbidden_consul .acl .replication ()
122101 self .assertFalse (result ['Enabled' ])
123102 self .assertFalse (result ['Running' ])
124103
125- @base .generate_key
126- def test_update_not_found_adds_new_key (self , acl_id ):
127- self .assertTrue (self .consul .acl .update (acl_id , 'Foo2' ))
104+ def test_update_not_found_adds_new_key (self ):
105+ acl_id = self .consul .acl .update (self .uuidv4 (), 'Foo2' )
128106 data = self .consul .acl .list ()
129107 self .assertIn ('Foo2' , [r .get ('Name' ) for r in data ])
130108 self .assertIn (acl_id , [r .get ('ID' ) for r in data ])
131109
132- @base .generate_key
133- def test_update_with_rules (self , acl_id ):
134- self .consul .acl .update (acl_id , name = 'test' , rules = ACL_RULES )
135- self .acl_list .append (acl_id )
110+ def test_update_with_rules (self ):
111+ acl_id = self .consul .acl .update (self .uuidv4 (), name = 'test' , rules = ACL_RULES )
136112 value = self .consul .acl .info (acl_id )
137113 self .assertEqual (value ['Rules' ], ACL_RULES )
138114
139- @base .generate_key
140- def test_update_forbidden (self , acl_id ):
115+ def test_update_forbidden (self ):
141116 with self .assertRaises (consulate .Forbidden ):
142- self .forbidden_consul .acl .update (acl_id , name = 'test' )
117+ self .forbidden_consul .acl .update (self . uuidv4 () , name = 'test' )
0 commit comments