Fakultas Ilmu Komputer UI

Commit 7d3082ab authored by Azhar Kurnia's avatar Azhar Kurnia
Browse files

increase coverage in core/models/*.py

parent 699e0588
from django.test import TestCase
from django.contrib.auth.models import User
from core.models.accounts import Company, Student, Supervisor
import datetime
class CompanyTest(TestCase):
class AccountTestCreation(TestCase):
def test_company_creation(self):
user = User.objects.create_user('dummy.login.company', 'dummy.login.company@company.com', 'lalala123')
company = Company.objects.create(user=user, description="lalalala", status=Company.VERIFIED, logo=None, address=None, category="perusahaan listrik", size="20", website="www.www", linkedin_url=None)
self.assertTrue(isinstance(company, Company))
self.assertEqual(company.__unicode__(), "Company " +company.name)
self.assertEqual(company.name.title(), "Dummy.Login.Company")
def test_supervisor_creation(self):
user = User.objects.create_user('dummy.login.supervisor', 'dummy.login.supervisor@supervisor.com', 'lalala123')
supervisor = Supervisor.objects.create(user=user, nip=100000000)
self.assertTrue(isinstance(supervisor, Supervisor))
self.assertEqual(supervisor.__unicode__(), "Supervisor " +supervisor.name)
self.assertEqual(supervisor.name.title(), "Dummy.Login.Supervisor")
def test_student_creation(self):
user = User.objects.create_user('dummy.login.student', 'dummy.login.student@student.com', 'lalala123')
student = Student.objects.create(user=user, npm=1606837631, resume=None, sertifikat=None, phone_number="081291693790", gender="laki-laki", birth_place="Jakarta")
student = Student.objects.create(user=user, npm=1606837631, resume=None, sertifikat=None, phone_number="081291693790", gender="laki-laki", birth_place="Jakarta", birth_date=datetime.datetime.now())
self.assertEqual(0, student.age)
self.assertEqual('dummy.login.student', student.full_name)
self.assertEqual(student.__unicode__(), "Student " +student.name)
self.assertTrue(isinstance(student, Student))
self.assertEqual(student.name.title(), "Dummy.Login.Student")
\ No newline at end of file
from django.test import TestCase
from django.contrib.auth.models import User
from core.models.accounts import Student
from core.models.recommendations import Recommendation
import datetime
class RecommendationsTestCreation(TestCase):
def test_student_creation(self):
user1 = User.objects.create_user('dummy.login.student1', 'dummy.login.student1@student1.com', 'lalala1231')
user2 = User.objects.create_user('dummy.login.student2', 'dummy.login.student2@student2.com', 'lalala1232')
student1 = Student.objects.create(user=user1, npm=1606837631, resume=None, sertifikat=None, phone_number="081291693790", gender="laki-laki", birth_place="Jakarta", birth_date=datetime.datetime.now())
student2 = Student.objects.create(user=user2, npm=1606918471, resume=None, sertifikat=None, phone_number="087887822443", gender="laki-laki", birth_place="Jakarta", birth_date=datetime.datetime.now())
recommendations = Recommendation.objects.create(recommendation_giver=student1, recommendation_receiver=student2)
self.assertEqual(recommendations.name, "Recommendation from {} to {}".format(student1.name, student2.name))
self.assertEqual(recommendations.__unicode__(), "Recommendation from {} to {}".format(student1.name, student2.name))
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment