Beispiel #1
0
    def test_get_user_if_exists(self):
        username = '******'
        details = {'username': username}

        # If no user exists, return an empty dict
        actual = get_user_if_exists(None, details)
        self.assertDictEqual(actual, {})

        # If user exists, return dict with user and any additional information
        user = G(self.user, username=username)
        actual = get_user_if_exists(None, details)
        self.assertDictEqual(actual, {'is_new': False, 'user': user})

        # If user passed to function, just return the additional information
        actual = get_user_if_exists(None, details, user=user)
        self.assertDictEqual(actual, {'is_new': False})
Beispiel #2
0
 def test_get_user_if_exists(self):
     """ Verify only the details are returned if a user is passed to the function. """
     user = User.objects.create(username=self.username)
     actual = get_user_if_exists(None, self.details, user=user)
     self.assertDictEqual(actual, {'is_new': False})
Beispiel #3
0
 def test_existing_user(self):
     """ Verify a dict with the user and extra details is returned if the user exists. """
     user = User.objects.create(username=self.username)
     actual = get_user_if_exists(None, self.details)
     self.assertDictEqual(actual, {'is_new': False, 'user': user})
Beispiel #4
0
 def test_no_user_exists(self):
     """ Verify an empty dict is returned if no user exists. """
     actual = get_user_if_exists(None, self.details)
     self.assertDictEqual(actual, {})