예제 #1
0
    def test_flush_memcache(self):
        check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': False,
            'ask_user_to_confirm_is_called': False
        }
        expected_check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': True,
            'ask_user_to_confirm_is_called': True
        }

        def mock_open_tab(unused_url):
            check_function_calls[
                'open_new_tab_in_browser_if_possible_is_called'] = True

        def mock_ask_user_to_confirm(unused_msg):
            check_function_calls['ask_user_to_confirm_is_called'] = True

        open_tab_swap = self.swap(common,
                                  'open_new_tab_in_browser_if_possible',
                                  mock_open_tab)
        ask_user_swap = self.swap(common, 'ask_user_to_confirm',
                                  mock_ask_user_to_confirm)
        with open_tab_swap, ask_user_swap:
            deploy.flush_memcache('oppiaserver')
        self.assertEqual(check_function_calls, expected_check_function_calls)
예제 #2
0
 def test_unsuccessful_flush_memcache(self):
     def mock_flush_memcache(unused_app_name):
         return False
     check_function_calls = {
         'open_tab_gets_called': False
     }
     expected_check_function_calls = {
         'open_tab_gets_called': True
     }
     def mock_open_tab(unused_url):
         check_function_calls['open_tab_gets_called'] = True
     flush_memcache_swap = self.swap(
         gcloud_adapter, 'flush_memcache', mock_flush_memcache)
     open_tab_swap = self.swap(
         common, 'open_new_tab_in_browser_if_possible', mock_open_tab)
     with flush_memcache_swap, open_tab_swap:
         deploy.flush_memcache('oppiaserver')
     self.assertEqual(check_function_calls, expected_check_function_calls)
예제 #3
0
    def test_flush_memcache_with_oppiatestserver(self):
        check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': False,
            'ask_user_to_confirm_is_called': False
        }
        expected_check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': True,
            'ask_user_to_confirm_is_called': True
        }
        check_url_list = {
            'https://console.cloud.google.com/appengine/'
            'memcache?src=ac&project=oppiatestserver':
            False,
            'https://oppiatestserver.appspot.com/admin#/misc':
            False
        }
        expected_check_url_list = {
            'https://console.cloud.google.com/appengine/'
            'memcache?src=ac&project=oppiatestserver':
            True,
            'https://oppiatestserver.appspot.com/admin#/misc':
            True
        }

        def mock_open_tab(url):
            check_function_calls[
                'open_new_tab_in_browser_if_possible_is_called'] = True
            check_url_list[url] = True

        def mock_ask_user_to_confirm(unused_msg):
            check_function_calls['ask_user_to_confirm_is_called'] = True

        open_tab_swap = self.swap(common,
                                  'open_new_tab_in_browser_if_possible',
                                  mock_open_tab)
        ask_user_swap = self.swap(common, 'ask_user_to_confirm',
                                  mock_ask_user_to_confirm)
        with open_tab_swap, ask_user_swap:
            deploy.flush_memcache('oppiatestserver')
        self.assertEqual(check_function_calls, expected_check_function_calls)
        self.assertEqual(check_url_list, expected_check_url_list)