def setUp(self): super().setUp() self.path = reverse('api:hospital:clients') self.client_1, self.client_2 = ClientFactory.create_batch(2) AccountFactory(user=self.user, client=self.client_1) AccountFactory(user=self.user, client=self.client_2) AccountFactory(client=self.client_2) AccountFactory.create_batch(2)
def test_put_method_authenticated_user_valid_params(self): account1, account2 = AccountFactory.create_batch(2, user=self.user) client1 = account1.client client2 = account2.client response = self.authorized_client.put( self.path, {'default_client_id': client1.id}) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertDictEqual( response.data, { 'email': self.user.email, 'name': self.user.name, 'default_client': { 'id': client1.id, 'name': client1.name, 'image': None }, 'admin_client': None, }) response = self.authorized_client.put( self.path, {'default_client_id': client2.id}) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertDictEqual( response.data, { 'email': self.user.email, 'name': self.user.name, 'default_client': { 'id': client2.id, 'name': client2.name, 'image': None }, 'admin_client': None, })
def test_form_invalid(self): client = ClientFactory() account = AccountFactory() form = RepCaseForm(data={'client': client.id, 'owners': [account.id]}) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['__all__'], [f'Invalid {account.role.name} {account.user.email} for {client.name}']) account_1, account_2, account_3 = AccountFactory.create_batch(3, client=client) form = RepCaseForm(data={'client': client.id, 'owners': [account_1.id, account_3.id], 'physician': account_2.id, 'procedure_date': '2000-11-22', 'status': NEW_CASE}) self.assertTrue(form.is_valid())
def setUp(self): doctor = RoleFactory(name='Physician', priority=1) hospital_admin = RoleFactory(name='Hospital Administrator', priority=10) self.client_1, self.client_2 = ClientFactory.create_batch(2) self.account_1 = AccountFactory(client=self.client_1, role=doctor) self.account_2 = AccountFactory(client=self.client_1, role=hospital_admin) self.account_3, self.account_4 = AccountFactory.create_batch( 2, client=self.client_2, role=doctor) super(ClientAccountsListingAdminTestCase, self).setUp() self.log_in_master_admin() self.visit_reverse('admin:hospital_account_changelist') self.wait_for_element_contains_text('#content h1', 'Select user account to change')
def setUp(self): super().setUp() self.hospital = ClientFactory() self.account_1, self.account_2 = AccountFactory.create_batch(2, client=self.hospital) AccountFactory() self.path = reverse('api:staff:accounts', args=(self.hospital.id,))