Пример #1
0
    def test_get_users_returns_correct_users(self, mock_user_class):
        mock_user_class.objects.all.return_value = [MagicMock(username='******'), MagicMock(username='******'),
                                                    MagicMock(username='******'), MagicMock(username='******')]
        actual = get_users(username='******')
        expected = ['joe', 'john']

        self.assertListEqual(actual, expected)
Пример #2
0
def users(request):
    if request.method == 'GET':
        username = request.GET.get('username', None)
        if username:
            response = get_users(username=username)
        else:
            response = []
        return HttpResponse(dumps(response))
    elif request.method == 'POST':
        username = _get_post_param(param='username', request=request)
        password = _get_post_param(param='password', request=request)
        response = add_user(username=username, password=password)
        return HttpResponse(dumps(response))
Пример #3
0
    def test_get_users_handles_no_users(self, mock_user_class):
        mock_user_class.objects.all.return_value = []
        actual = get_users(username='******')
        expected = []

        self.assertListEqual(actual, expected)