<gh_stars>0
# IMPORTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Third party
from django.test import TestCase
from django.contrib.auth.models import User

# Internal
from checkout.models import Order
from profiles.models import UserProfile
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


class TestProfileViews(TestCase):

    def setUp(self):
        """
         This setup creates a test user,
         test product and test order
         """
        testuser = User.objects.create_user(
            username='test_user',
            password='<PASSWORD>',
            email='<EMAIL>')
        testuser.save()

        Order.objects.create(
            order_number='12345678',
            user_profile=UserProfile.objects.get(user=testuser),
            full_name='<NAME>',
            email='<EMAIL>',
            phone_number='12345678',
            country='Test Country',
            postcode='Test postcode',
            town_or_city='Test city',
            street_address1='Test address',
            county='Test country',
        )

    def tearDown(self):
        """
        Delete test user and order
        """
        User.objects.all().delete()
        Order.objects.all().delete()

    def test_get_profile_page(self):
        """
        This test logins a test user and
        accesses their profile page (get) and verifies
        """
        self.client.login(username='test_user', password='<PASSWORD>')
        response = self.client.get('/profile/')
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'profiles/profile.html')

# IMPORTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Third party
from django.test import TestCase
from django.contrib.auth.models import User

# Internal
from checkout.models import Order
from profiles.models import UserProfile
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


class TestProfileViews(TestCase):

    def setUp(self):
        """
         This setup creates a test user,
         test product and test order
         """
        testuser = User.objects.create_user(
            username='test_user',
            password='<PASSWORD>',
            email='<EMAIL>')
        testuser.save()

        Order.objects.create(
            order_number='12345678',
            user_profile=UserProfile.objects.get(user=testuser),
            full_name='<NAME>',
            email='<EMAIL>',
            phone_number='12345678',
            country='Test Country',
            postcode='Test postcode',
            town_or_city='Test city',
            street_address1='Test address',
            county='Test country',
        )

    def tearDown(self):
        """
        Delete test user and order
        """
        User.objects.all().delete()
        Order.objects.all().delete()

    def test_get_profile_page(self):
        """
        This test logins a test user and
        accesses their profile page (get) and verifies
        """
        self.client.login(username='test_user', password='<PASSWORD>')
        response = self.client.get('/profile/')
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'profiles/profile.html')
# IMPORTS # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Third party # Internal # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This setup creates a test user,          test product and test order Delete test user and order This test logins a test user and         accesses their profile page (get) and verifies