def test_convert_string_fail(self): """ Tests that the parameter fails validation if the username doesn't exist """ expected_user = '******' param = User() param.convert(expected_user, None, None)
def test_convert_int_fail(self): """ Tests that the parameter fails validation if the UID doesn't exist """ # This should be way larger than the system limit since its 2^64 user_id = 0x10000000000000000 param = User() param.convert(user_id, None, None)
def test_convert_int(self): """ Tests that the parameter validates UID's exist """ expected_uid = os.getuid() param = User() user = param.convert(expected_uid, None, None) self.assertEqual( expected_uid, user, 'User ID did not match', )
def test_convert_string(self): """ Tests that the parameter type properly converts a username string """ current_user = getpass.getuser() param = User() user = param.convert(current_user, None, None) self.assertEqual( os.getuid(), user, 'User did not match', )