I'm experiencing issues on creating fixtures for a particular model in a test class with Django and the DRF. I'm using model-mommy <https://model-mommy.readthedocs.io/en/latest/index.html>, but even creating a single instance just using the Django ORM for that model does not work:
* from rest_framework.test import APIRequestFactory, APITestCase* * from model_mommy import mommy* * from api.v1 import views* * from company.models.models import CompanyUserProfile, ManagerRelation, DynamicRelation* * User = get_user_model()* * class APIViewsTestCase(APITestCase):* * @classmethod* * def setUpTestData(cls):* * supervisory_id = "1337"* * emp_group_id = "119"* * prd_scope_id = "1334"* * user = mommy.make(User)* * setattr(cls, 'user', user)* * company_user_profile_1 = mommy.make(CompanyUserProfile)* * requestor = mommy.make(* * CompanyUserProfile, is_manager=True,* * supervisory_id=supervisory_id, emp_group_id=emp_group_id,* * prd_scope_id=prd_scope_id, user=user* * )* * cls.user = user* * manager_relation = mommy.make(* * ManagerRelation, manager_id=requestor.id, mgr_type="Direct Mgr", _quantity=5* * )* * dynamic_relations = mommy.make(* * DynamicRelation,target_id=requestor.id, _quantity=5* * )* * def setUp(self) -> None:* * super().setUp()* * self.client.force_authenticate(user=self.user)* * def test_employee_view(self):* * CompanyUserProfile.objects.create(* * guid=uuid.uuid4(),* * comp_user_id='idcbijnccdocwocd', comp_username='djchbdcjnwdskjcn',* * id=3333* * )* * print('cup count:', CompanyUserProfile.objects.count())* * print('user count:', User.objects.count())* * print('m_rels count:', ManagerRelation.objects.count())* * print('d_rels count:', DynamicRelation.objects.count())* * rsp = self.client.get('/api/v1/employees/')* * self.assertEqual(rsp.status_code, HTTPStatus.OK)* however *CompanyUserProfile* records are not created, both using *mommy.make* or *CompanyUserProfile.objects.create*: * -- test run output: python manage.py test* * Creating test database for alias 'default'...* * System check identified no issues (0 silenced).* * cup count: 0* * user count: 1* * m_rels count: 5* * d_rels count: 5* * Destroying test database for alias 'default'...* *CompanyUserProfile* inherits from *AbstractCompanyUserProfile* (abstract base model), that's the main difference between this and the other models. Any idea of what can be the root cause of this? *Python: 3.6.5* *Django: 1.11.15* *model-mommy: 1.6.0* *PostgreSQL: 9.6.10* Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c1c1c7c6-3565-4af9-8f0a-d4012228caa3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.