Fakultas Ilmu Komputer UI

test_account_models.py 1.82 KB
Newer Older
1
2
3
from django.test import TestCase
from django.contrib.auth.models import User
from core.models.accounts import Company, Student, Supervisor
4
import datetime
5

6
class AccountTestCreation(TestCase):
7
8
9
10
11

    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))
12
        self.assertEqual(company.__unicode__(), "Company " +company.name) 
13
14
15
16
17
18
        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))
19
        self.assertEqual(supervisor.__unicode__(), "Supervisor " +supervisor.name) 
20
21
22
23
        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')
24
25
26
27
        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) 
28
29
        self.assertTrue(isinstance(student, Student))
        self.assertEqual(student.name.title(), "Dummy.Login.Student")