'Assert that the L{Deferred} passed in is called back with the value
\'username\'.  This represents a valid login for this TestCase.
NOTE: To work, this method\'s return value must be returned from the
test method, or otherwise hooked up to the test machinery.
@param d: a L{Deferred} from an L{IChecker.requestAvatarId} method.
@type d: L{Deferred}
@rtype: L{Deferred}'

def assertLoggedIn(self, d, username):

    result = []
    d.addBoth(result.append)
    self.assertEqual(len(result), 1, 'login    incomplete')
    if isinstance(result[0], Failure):
        result[0].raiseException()
    self.assertEqual(result[0], username)
