Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- class UserId(models.Model):
- userId = models.IntegerField(unique=True)
- class Contact(models.Model):
- userId = models.ForeignKey('UserId', on_delete=models.CASCADE)
- name = models.CharField(max_length=50)
- email = models.EmailField(unique=True)
- phone = models.IntegerField(unique=True)
- def __str__(self):
- return self.name
- from django.test import TestCase
- from ng.models import Contact
- class TestContactModel(TestCase):
- def setUp(self):
- self.contact = Contact(userId=25, name='jhon doe', email='testt@fk.com', phone=215448)
- self.contact.save()
- def test_contact_creation(self):
- self.assertEqual(Contact.objects.count(), 1)
- def test_contact_representation(self):
- self.assertEqual(self.contact.name, str(self.contact))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement