Exemple #1
0
 def test_update_layers_with_process_already_running(self):
     """
     Popen() is not called if an "updatelayers" process is running already.
     """
     popen_mock = mock.MagicMock(name="mock:subprocess.Popen")
     with mock.patch('geonode.mtapi.view_utils.is_process_running') as mock_func:
         mock_func.return_value = True
         with mock.patch('subprocess.Popen', new=popen_mock):
             update_layers()
             self.assertEqual(0, popen_mock.call_count)
Exemple #2
0
 def test_update_layers(self):
     """
     Popen() is called correctly if no "updatelayers" process is running.
     """
     popen_mock = mock.MagicMock(name="mock:subprocess.Popen")
     with mock.patch('geonode.mtapi.view_utils.is_process_running') as mock_func:
         mock_func.return_value = False
         with mock.patch('subprocess.Popen', new=popen_mock):
             update_layers()
             self.assertEqual(1, popen_mock.call_count)
             args, _kwargs = popen_mock.call_args
             self.assertEqual((settings.OQ_UPDATE_LAYERS_PATH,), args)