@@ -62,13 +62,24 @@ def app_credential(request):
6262 yield provider .get ()
6363 provider .cleanup ()
6464
65+ @pytest .fixture (params = [None , 'myApp' ], ids = ['DefaultApp' , 'CustomApp' ])
66+ def init_app (request ):
67+ if request .param :
68+ return firebase_admin .initialize_app (CREDENTIAL , name = request .param )
69+ else :
70+ return firebase_admin .initialize_app (CREDENTIAL )
71+
6572
6673class TestFirebaseApp (object ):
6774 """Test cases for App initialization and life cycle."""
6875
6976 invalid_credentials = ['' , 'foo' , 0 , 1 , dict (), list (), tuple (), True , False ]
7077 invalid_options = ['' , 0 , 1 , list (), tuple (), True , False ]
7178 invalid_names = [None , '' , 0 , 1 , dict (), list (), tuple (), True , False ]
79+ invalid_apps = [
80+ None , '' , 0 , 1 , dict (), list (), tuple (), True , False ,
81+ firebase_admin .App ('uninitialized' , CREDENTIAL , {})
82+ ]
7283
7384 def teardown_method (self ):
7485 testutils .cleanup_apps ()
@@ -108,13 +119,8 @@ def test_app_init_with_invalid_name(self, name):
108119 with pytest .raises (ValueError ):
109120 firebase_admin .initialize_app (CREDENTIAL , name = name )
110121
111- def test_default_app_get (self ):
112- app = firebase_admin .initialize_app (CREDENTIAL )
113- assert app is firebase_admin .get_app ()
114-
115- def test_non_default_app_get (self ):
116- app = firebase_admin .initialize_app (CREDENTIAL , name = 'myApp' )
117- assert app is firebase_admin .get_app ('myApp' )
122+ def test_app_get (self , init_app ):
123+ assert init_app is firebase_admin .get_app (init_app .name )
118124
119125 @pytest .mark .parametrize ('args' , [(), ('myApp' ,)],
120126 ids = ['DefaultApp' , 'CustomApp' ])
@@ -126,3 +132,16 @@ def test_non_existing_app_get(self, args):
126132 def test_app_get_with_invalid_name (self , name ):
127133 with pytest .raises (ValueError ):
128134 firebase_admin .get_app (name )
135+
136+ @pytest .mark .parametrize ('app' , invalid_apps )
137+ def test_invalid_app_delete (self , app ):
138+ with pytest .raises (ValueError ):
139+ firebase_admin .delete_app (app )
140+
141+ def test_app_delete (self , init_app ):
142+ assert firebase_admin .get_app (init_app .name ) is init_app
143+ firebase_admin .delete_app (init_app )
144+ with pytest .raises (ValueError ):
145+ firebase_admin .get_app (init_app .name )
146+ with pytest .raises (ValueError ):
147+ firebase_admin .delete_app (init_app )
0 commit comments