Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. from django.db import models
  2.  
  3. class UserId(models.Model):
  4. userId = models.IntegerField(unique=True)
  5.  
  6. class Contact(models.Model):
  7. userId = models.ForeignKey('UserId', on_delete=models.CASCADE)
  8. name = models.CharField(max_length=50)
  9. email = models.EmailField(unique=True)
  10. phone = models.IntegerField(unique=True)
  11.  
  12. def __str__(self):
  13. return self.name
  14.  
  15. from django.test import TestCase
  16. from ng.models import Contact
  17.  
  18.  
  19. class TestContactModel(TestCase):
  20. def setUp(self):
  21. self.contact = Contact(userId=25, name='jhon doe', email='testt@fk.com', phone=215448)
  22. self.contact.save()
  23.  
  24. def test_contact_creation(self):
  25. self.assertEqual(Contact.objects.count(), 1)
  26.  
  27. def test_contact_representation(self):
  28. self.assertEqual(self.contact.name, str(self.contact))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement