예제 #1
0
 def contacts_and_accounts(self, size, tenant):
     # create various contacts
     ContactFactory.create_batch(size, tenant=tenant)
     # create accounts with zero contact
     AccountFactory.create_batch(size, tenant=tenant)
     # create account with multi contacts
     function_factory(tenant).create_batch(size, account=AccountFactory(tenant=tenant))
예제 #2
0
 def contacts_and_accounts(self, size, tenant):
     # create various contacts
     ContactFactory.create_batch(size, tenant=tenant)
     # create accounts with zero contact
     AccountFactory.create_batch(size, tenant=tenant)
     # create account with multi contacts
     function_factory(tenant).create_batch(
         size, account=AccountFactory(tenant=tenant))
     # create account with assigned_to
     function_factory(tenant).create_batch(
         size,
         account=AccountFactory(tenant=tenant,
                                assigned_to=LilyUserFactory(tenant=tenant)))
예제 #3
0
    def contacts_contact(self, **kwargs):
        kwargs.update({"size": kwargs.get("size", self.batch_size), "tenant": kwargs.get("tenant", self.tenant)})
        contacts = ContactFactory.create_batch(**kwargs)

        self.stdout.write("Done with contacts_contact.")

        return contacts
예제 #4
0
    def contacts_contact(self, **kwargs):
        kwargs.update({
            'size': kwargs.get('size', self.batch_size),
            'tenant': kwargs.get('tenant', self.tenant),
        })
        contacts = ContactFactory.create_batch(**kwargs)

        self.stdout.write('Done with contacts_contact.')

        return contacts
예제 #5
0
    def contacts_contact(self, **kwargs):
        kwargs.update({
            'size': kwargs.get('size', self.batch_size),
            'tenant': kwargs.get('tenant', self.tenant),
        })
        contacts = ContactFactory.create_batch(**kwargs)

        self.stdout.write('Done with contacts_contact.')

        return contacts
예제 #6
0
 def contacts_and_accounts(self, size, tenant):
     # create various contacts
     ContactFactory.create_batch(size, tenant=tenant)
     # create accounts with zero contact
     AccountFactory.create_batch(size, tenant=tenant)
     # create account with multi contacts
     FunctionFactory.create_batch(
         size,
         tenant=tenant,
         account=AccountFactory(tenant=tenant),
     )
     # create account with assigned_to
     FunctionFactory.create_batch(
         size,
         tenant=tenant,
         account=AccountFactory(
             tenant=tenant,
             assigned_to=LilyUserFactory(tenant=tenant)
         ),
     )
예제 #7
0
    def test_update_modified(self):
        """
        Test that the modified date of a case gets set properly.
        """
        tenant = TenantFactory.create()
        contact = ContactFactory.create(tenant=tenant)
        modified = contact.modified

        time.sleep(1)

        contact.save(update_modified=False)
        self.assertEqual(modified, contact.modified)

        contact.save(update_modified=True)
        self.assertNotEqual(modified, contact.modified)
예제 #8
0
    def setUpTestData(cls):
        super(InternalNumberSearchAPITestCase, cls).setUpTestData()

        cls.four_days_ago = datetime.now(tz=utc) - timedelta(days=4)
        cls.five_days_ago = datetime.now(tz=utc) - timedelta(days=5)
        cls.nine_days_ago = datetime.now(tz=utc) - timedelta(days=9)

        cls.case_status_new = CaseStatusFactory.create(tenant=cls.user_obj.tenant, name='New')
        cls.case_status_closed = CaseStatusFactory.create(tenant=cls.user_obj.tenant, name='Closed')
        cls.deal_status_open = DealStatusFactory.create(tenant=cls.user_obj.tenant, name='Open')
        cls.deal_status_lost = DealStatusFactory.create(tenant=cls.user_obj.tenant, name='Lost')

        cls.phone_number = PhoneNumberFactory(tenant=cls.user_obj.tenant, number='+31611223344')
        cls.contact = ContactFactory.create(tenant=cls.user_obj.tenant)
        cls.contact.phone_numbers.add(cls.phone_number)
예제 #9
0
    def _create_object_stub(self, with_relations=False, size=1, **kwargs):
        """
        Create an object dict with relation dicts using factories.
        """
        # Set a default tenant of the user.
        kwargs['tenant'] = self.user_obj.tenant if not kwargs.get('tenant') else kwargs['tenant']

        object_list = []
        casetype = CaseTypeFactory(**kwargs)
        casestatus = CaseStatusFactory(**kwargs)

        for iteration in range(0, size):
            obj = self.factory_cls.stub(**kwargs).__dict__
            del obj['tenant']

            # The minimum viable case instance needs these relations, so always make them.
            obj['type'] = {
                'id': casetype.pk
            }
            obj['status'] = {
                'id': casestatus.pk
            }

            if with_relations:
                # If relations are needed, override them, because a dict is needed instead of an instance.
                obj['account'] = AccountFactory.stub().__dict__
                obj['contact'] = ContactFactory.stub().__dict__
                obj['assigned_to'] = LilyUserFactory.stub().__dict__

                del obj['account']['tenant']
                del obj['contact']['tenant']
                del obj['assigned_to']['tenant']
                del obj['created_by']
            else:
                # Delete the related objects, since they can't be serialized.
                del obj['account']
                del obj['assigned_to']
                del obj['created_by']

            object_list.append(obj)

        if size > 1:
            return object_list
        else:
            # If required size is 1, just give the object instead of a list.
            return object_list[0]
예제 #10
0
    def _create_object_stub(self, with_relations=False, size=1, **kwargs):
        """
        Create an object dict with relation dicts using factories.
        """
        # Set a default tenant of the user.
        kwargs['tenant'] = self.user_obj.tenant if not kwargs.get(
            'tenant') else kwargs['tenant']

        object_list = []
        casetype = CaseTypeFactory(**kwargs)
        casestatus = CaseStatusFactory(**kwargs)

        for iteration in range(0, size):
            obj = self.factory_cls.stub(**kwargs).__dict__
            del obj['tenant']

            # The minimum viable case instance needs these relations, so always make them.
            obj['type'] = {'id': casetype.pk}
            obj['status'] = {'id': casestatus.pk}

            if with_relations:
                # If relations are needed, override them, because a dict is needed instead of an instance.
                obj['account'] = AccountFactory.stub().__dict__
                obj['contact'] = ContactFactory.stub().__dict__
                obj['assigned_to'] = LilyUserFactory.stub().__dict__

                del obj['account']['tenant']
                del obj['contact']['tenant']
                del obj['assigned_to']['tenant']
                del obj['created_by']
            else:
                # Delete the related objects, since they can't be serialized.
                del obj['account']
                del obj['assigned_to']
                del obj['created_by']

            object_list.append(obj)

        if size > 1:
            return object_list
        else:
            # If required size is 1, just give the object instead of a list.
            return object_list[0]
예제 #11
0
    def setUpTestData(cls):
        super(InternalNumberSearchAPITestCase, cls).setUpTestData()

        cls.four_days_ago = datetime.now(tz=utc) - timedelta(days=4)
        cls.five_days_ago = datetime.now(tz=utc) - timedelta(days=5)
        cls.nine_days_ago = datetime.now(tz=utc) - timedelta(days=9)

        cls.case_status_new = CaseStatusFactory.create(
            tenant=cls.user_obj.tenant, name='New')
        cls.case_status_closed = CaseStatusFactory.create(
            tenant=cls.user_obj.tenant, name='Closed')
        cls.deal_status_open = DealStatusFactory.create(
            tenant=cls.user_obj.tenant, name='Open')
        cls.deal_status_lost = DealStatusFactory.create(
            tenant=cls.user_obj.tenant, name='Lost')

        cls.phone_number = PhoneNumberFactory(tenant=cls.user_obj.tenant,
                                              number='+31611223344')
        cls.contact = ContactFactory.create(tenant=cls.user_obj.tenant)
        cls.contact.phone_numbers.add(cls.phone_number)