<gh_stars>0
from django.test import TestCase
from .models import Profile,Project,Rating
from django.contrib.auth.models import User


# Create your tests here.
class ProfileTestClass(TestCase):
    # Set up method
    def setUp(self):
        """Creating a new location and saving it"""
        user = User.objects.create(username='kibet',first_name='rono',last_name='David')

        self.profile=Profile.objects.create(user=user,profile_photo='lorem2.png',bio="New description",contact=1)
        self.profile.save_profile()

    def test_instance(self):
        """Testing instance"""
        self.assertTrue(isinstance(self.profile, Profile))

    def test_save_method(self):
        """Testing Save Method"""
        self.profile.save_profile()
        profile = Profile.objects.all()
        self.assertTrue(len(profile) > 0)

    def test_delete_method(self):
        """Testing delete Method"""
        self.profile.delete_profile()
        profile = Profile.objects.all()
        self.assertTrue(len(profile) < 1)

    def tearDown(self):
        """tearDown method"""
        Profile.objects.all().delete()


class ProjectTestClass(TestCase):
    # Set up method
    def setUp(self):
        """Creating a new location and saving it"""
        user = User.objects.create(username='kibet',first_name='rono',last_name='David')

        self.project=Project.objects.create(user=user,title="project 1",description="Initial project",image='lorem2.png',url="https://ksms.or.ke/contact-us-3/",location="New description",date=None)
        self.project.save_project()

    def test_instance(self):
        """Testing instance"""
        self.assertTrue(isinstance(self.project, Project))

    def test_save_method(self):
        """Testing Save Method"""
        self.project.save_project()
        project = Project.objects.all()
        self.assertTrue(len(project) > 0)

    def test_delete_method(self):
        """Testing delete Method"""
        self.project.delete_project()
        project= Project.objects.all()
        self.assertTrue(len(project) < 1)

    def tearDown(self):
        """tearDown method"""
        Project.objects.all().delete()


class RatingTestClass(TestCase):
    # Set up method
    def setUp(self):
        """Creating a new rating and saving it"""
        user = User.objects.create(username='kibet',first_name='rono',last_name='David')
        self.project=Project.objects.create(user=user,title="project 1",description="Initial project",image='lorem2.png',url="https://ksms.or.ke/contact-us-3/",location="New description",date=None)
        self.project.save_project()
        self.rating=Rating.objects.create(user=user,project=self.project,design_rate=1,usability_rate=3,content_rate=5,avg_rate=3,date=None)
        self.rating.save_rating()

    def test_instance(self):
        """Testing instance"""
        self.assertTrue(isinstance(self.rating, Rating))

    def test_save_method(self):
        """Testing Save Method"""
        self.rating.save_rating()
        rating = Rating.objects.all()
        self.assertTrue(len(rating) > 0)

    def test_delete_method(self):
        """Testing delete Method"""
        self.rating.delete_rating()
        rating= Rating.objects.all()
        self.assertTrue(len(rating) < 1)

    def tearDown(self):
        """tearDown method"""
        Rating.objects.all().delete()




from django.test import TestCase
from .models import Profile,Project,Rating
from django.contrib.auth.models import User


# Create your tests here.
class ProfileTestClass(TestCase):
    # Set up method
    def setUp(self):
        """Creating a new location and saving it"""
        user = User.objects.create(username='kibet',first_name='rono',last_name='David')

        self.profile=Profile.objects.create(user=user,profile_photo='lorem2.png',bio="New description",contact=1)
        self.profile.save_profile()

    def test_instance(self):
        """Testing instance"""
        self.assertTrue(isinstance(self.profile, Profile))

    def test_save_method(self):
        """Testing Save Method"""
        self.profile.save_profile()
        profile = Profile.objects.all()
        self.assertTrue(len(profile) > 0)

    def test_delete_method(self):
        """Testing delete Method"""
        self.profile.delete_profile()
        profile = Profile.objects.all()
        self.assertTrue(len(profile) < 1)

    def tearDown(self):
        """tearDown method"""
        Profile.objects.all().delete()


class ProjectTestClass(TestCase):
    # Set up method
    def setUp(self):
        """Creating a new location and saving it"""
        user = User.objects.create(username='kibet',first_name='rono',last_name='David')

        self.project=Project.objects.create(user=user,title="project 1",description="Initial project",image='lorem2.png',url="https://ksms.or.ke/contact-us-3/",location="New description",date=None)
        self.project.save_project()

    def test_instance(self):
        """Testing instance"""
        self.assertTrue(isinstance(self.project, Project))

    def test_save_method(self):
        """Testing Save Method"""
        self.project.save_project()
        project = Project.objects.all()
        self.assertTrue(len(project) > 0)

    def test_delete_method(self):
        """Testing delete Method"""
        self.project.delete_project()
        project= Project.objects.all()
        self.assertTrue(len(project) < 1)

    def tearDown(self):
        """tearDown method"""
        Project.objects.all().delete()


class RatingTestClass(TestCase):
    # Set up method
    def setUp(self):
        """Creating a new rating and saving it"""
        user = User.objects.create(username='kibet',first_name='rono',last_name='David')
        self.project=Project.objects.create(user=user,title="project 1",description="Initial project",image='lorem2.png',url="https://ksms.or.ke/contact-us-3/",location="New description",date=None)
        self.project.save_project()
        self.rating=Rating.objects.create(user=user,project=self.project,design_rate=1,usability_rate=3,content_rate=5,avg_rate=3,date=None)
        self.rating.save_rating()

    def test_instance(self):
        """Testing instance"""
        self.assertTrue(isinstance(self.rating, Rating))

    def test_save_method(self):
        """Testing Save Method"""
        self.rating.save_rating()
        rating = Rating.objects.all()
        self.assertTrue(len(rating) > 0)

    def test_delete_method(self):
        """Testing delete Method"""
        self.rating.delete_rating()
        rating= Rating.objects.all()
        self.assertTrue(len(rating) < 1)

    def tearDown(self):
        """tearDown method"""
        Rating.objects.all().delete()
# Create your tests here. # Set up method Creating a new location and saving it Testing instance Testing Save Method Testing delete Method tearDown method # Set up method Creating a new location and saving it Testing instance Testing Save Method Testing delete Method tearDown method # Set up method Creating a new rating and saving it Testing instance Testing Save Method Testing delete Method tearDown method