# Path: adl_lrs/views.py
# @csrf_protect
# @require_http_methods(["POST", "GET"])
# def register(request):
#     if request.method == 'GET':
#         form = RegisterForm()
#         return render(request, 'register.html', {"form": form})
#     elif request.method == 'POST':
#         form = RegisterForm(request.POST)
#         if form.is_valid():
#             name = form.cleaned_data['username']
#             pword = form.cleaned_data['password']
#             email = form.cleaned_data['email']
# 
#             # If username doesn't already exist
#             if not User.objects.filter(username__exact=name).count():
#                 # if email doesn't already exist
#                 if not User.objects.filter(email__exact=email).count():
#                     User.objects.create_user(name, email, pword)
#                 else:
#                     return render(request, 'register.html', {"form": form, "error_message": "Email %s is already registered." % email})
#             else:
#                 return render(request, 'register.html', {"form": form, "error_message": "User %s already exists." % name})
# 
#             # If a user is already logged in, log them out
#             if request.user.is_authenticated:
#                 logout(request)
# 
#             new_user = authenticate(username=name, password=pword)
#             login(request, new_user)
#             return HttpResponseRedirect(reverse('home'))
#         else:
#             return render(request, 'register.html', {"form": form})


import hashlib
import urllib.request, urllib.parse, urllib.error
import base64
import json
import ast
        import ast
from django.test import TestCase
from django.conf import settings
from django.urls import reverse
from adl_lrs.views import register




class AgentProfileTests(TestCase):
    testagent = '{"mbox":"mailto:test@example.com"}'
    otheragent = '{"mbox":"mailto:other@example.com"}'
    content_type = "application/json"
    testprofileId1 = "http://profile.test.id/test/1"
    testprofileId2 = "http://profile.test.id/test/2"
    testprofileId3 = "http://profile.test.id/test/3"
    otherprofileId1 = "http://profile.test.id/other/1"

    @classmethod
    def setUpClass(cls):
        print("\n%s" % __name__)
        super(AgentProfileTests, cls).setUpClass()

    def setUp(self):
        self.username = "tester"
        self.email = "test@tester.com"
        self.password = "test"
        self.auth = "Basic %s" % base64.b64encode(
            "%s:%s" % (self.username, self.password))
        form = {'username': self.username, 'email': self.email,
                'password': self.password, 'password2': self.password}

# Path: adl_lrs/views.py
# @csrf_protect
# @require_http_methods(["POST", "GET"])
# def register(request):
#     if request.method == 'GET':
#         form = RegisterForm()
#         return render(request, 'register.html', {"form": form})
#     elif request.method == 'POST':
#         form = RegisterForm(request.POST)
#         if form.is_valid():
#             name = form.cleaned_data['username']
#             pword = form.cleaned_data['password']
#             email = form.cleaned_data['email']
# 
#             # If username doesn't already exist
#             if not User.objects.filter(username__exact=name).count():
#                 # if email doesn't already exist
#                 if not User.objects.filter(email__exact=email).count():
#                     User.objects.create_user(name, email, pword)
#                 else:
#                     return render(request, 'register.html', {"form": form, "error_message": "Email %s is already registered." % email})
#             else:
#                 return render(request, 'register.html', {"form": form, "error_message": "User %s already exists." % name})
# 
#             # If a user is already logged in, log them out
#             if request.user.is_authenticated:
#                 logout(request)
# 
#             new_user = authenticate(username=name, password=pword)
#             login(request, new_user)
#             return HttpResponseRedirect(reverse('home'))
#         else:
#             return render(request, 'register.html', {"form": form})


# Path: lrs/tests/test_AgentProfile.py
import hashlib
import urllib.request, urllib.parse, urllib.error
import base64
import json
import ast
        import ast
from django.test import TestCase
from django.conf import settings
from django.urls import reverse
from adl_lrs.views import register





class AgentProfileTests(TestCase):
    testagent = '{"mbox":"mailto:test@example.com"}'
    otheragent = '{"mbox":"mailto:other@example.com"}'
    content_type = "application/json"
    testprofileId1 = "http://profile.test.id/test/1"
    testprofileId2 = "http://profile.test.id/test/2"
    testprofileId3 = "http://profile.test.id/test/3"
    otherprofileId1 = "http://profile.test.id/other/1"

    @classmethod
    def setUpClass(cls):
        print("\n%s" % __name__)
        super(AgentProfileTests, cls).setUpClass()

    def setUp(self):
        self.username = "tester"
        self.email = "test@tester.com"
        self.password = "test"
        self.auth = "Basic %s" % base64.b64encode(
            "%s:%s" % (self.username, self.password))
        form = {'username': self.username, 'email': self.email,
                'password': self.password, 'password2': self.password}

        self.client.post(reverse(register), form,