def test_stop_uwsgi_does_nothing_when_uwsgi_is_not_running(self, check_process_mock): """ tests that stop_uwsgi does nothing when uwsgi is not running """ mocks.alt_bool = Alternate([False]) install_django_app = InstallDjangoApp( self.dist_version, self.log_file, self.log_level, venv=self.venv, git_repo=self.git_repo, ) install_django_app.stop_uwsgi() self.log('INFO: did not stop uwsgi, was not running') self.assertEqual( [call('uwsgi')], check_process_mock.mock_calls, check_process_mock.mock_calls )
def test_stop_uwsgi(self, check_process_mock): """ tests that stop_uwsgi writes to fifo and writes to log """ djangoapp.FIFO_DIR = self.fifo_dir mocks.alt_bool = Alternate([True]) os.makedirs(os.path.join(self.fifo_dir, self.app_name)) install_django_app = InstallDjangoApp(self.dist_version, self.log_file, self.log_level, git_repo=self.git_repo, fifo_dir=self.fifo_dir ) install_django_app.stop_uwsgi() with open(os.path.join(self.fifo_dir, 'fifo0')) as fifo: fifo_list = [l for l in fifo] self.assertEqual(['q'], fifo_list, fifo_list) self.log('INFO: stopped uwsgi server') self.assertEqual( [call('uwsgi')], check_process_mock.mock_calls, check_process_mock.mock_calls )