def test_userdel(self): ''' Test if it delete an HTTP user from the specified htpasswd file. ''' mock = MagicMock(return_value='Salt') with patch.dict(htpasswd.__salt__, {'cmd.run': mock}): self.assertEqual(htpasswd.userdel('/etc/httpd/htpasswd', 'larry'), ['Salt'])
def test_userdel_missing_htpasswd(self): ''' Test if it returns error when no htpasswd file exists ''' with patch('os.path.exists', MagicMock(return_value=False)): self.assertEqual( htpasswd.userdel('/etc/httpd/htpasswd', 'larry'), 'Error: The specified htpasswd file does not exist')
def test_userdel_missing_htpasswd(self): ''' Test if it returns error when no htpasswd file exists ''' self.assertEqual(htpasswd.userdel('/etc/httpd/htpasswd', 'larry'), 'Error: The specified htpasswd file does not exist')