def test_exists_with_wrong_perms(self, mock_stderr, mock_expanduser): mock_expanduser.return_value = self.pulppath os.mkdir(self.pulppath, 0755) launcher.ensure_user_pulp_dir() self.assertEqual(mock_stderr.write.call_count, 1) message = mock_stderr.write.call_args[0][0] # make sure it prints a warning to stderr self.assertTrue(message.startswith('Warning:'))
def test_does_not_exist(self, mock_expanduser): mock_expanduser.return_value = self.pulppath launcher.ensure_user_pulp_dir() stats = os.stat(os.path.join(self.workingdir, '.pulp')) actual_mode = stat.S_IMODE(stats.st_mode) desired_mode = stat.S_IRUSR + stat.S_IWUSR + stat.S_IXUSR self.assertEqual(actual_mode, desired_mode)
def test_fail_to_create(self, mock_stderr, mock_exit, mock_mkdir, mock_expanduser): mock_expanduser.return_value = self.pulppath launcher.ensure_user_pulp_dir() mock_exit.assert_called_once_with(1) self.assertEqual(mock_stderr.write.call_count, 1) message = mock_stderr.write.call_args[0][0] # make sure it prints a warning to stderr self.assertTrue(message.startswith('Failed to create'))
def test_asks_for_correct_dir(self, mock_expanduser): mock_expanduser.return_value = self.pulppath launcher.ensure_user_pulp_dir() mock_expanduser.assert_called_once_with(constants.USER_CONFIG_DIR)