示例#1
0
文件: tests.py 项目: Ilhasoft/ureport
    def test_kwargs_from_temba(self):
        temba_contact_field = TembaContactField.create(key='foo', label='Bar', value_type='T')

        kwargs = ContactField.kwargs_from_temba(self.nigeria, temba_contact_field)
        self.assertEqual(kwargs, dict(org=self.nigeria, key='foo', label='Bar', value_type='T'))

        # try creating contact from them
        ContactField.objects.create(**kwargs)
示例#2
0
文件: tests.py 项目: Ilhasoft/ureport
    def test_update_or_create_from_temba(self):
        temba_contact_field = TembaContactField.create(key='foo', label='Bar', value_type='T')

        field = ContactField.update_or_create_from_temba(self.nigeria, temba_contact_field)

        self.assertEqual(field.key, 'foo')
        self.assertEqual(field.label, 'Bar')

        updated_field = ContactField.update_or_create_from_temba(self.nigeria, temba_contact_field)

        self.assertEqual(field.pk, updated_field.pk)
示例#3
0
    def test_kwargs_from_temba(self):
        temba_contact_field = TembaContactField.create(key='foo',
                                                       label='Bar',
                                                       value_type='T')

        kwargs = ContactField.kwargs_from_temba(self.nigeria,
                                                temba_contact_field)
        self.assertEqual(
            kwargs,
            dict(org=self.nigeria, key='foo', label='Bar', value_type='T'))

        # try creating contact from them
        ContactField.objects.create(**kwargs)
示例#4
0
    def test_update_or_create_from_temba(self):
        temba_contact_field = TembaContactField.create(key='foo',
                                                       label='Bar',
                                                       value_type='T')

        field = ContactField.update_or_create_from_temba(
            self.nigeria, temba_contact_field)

        self.assertEqual(field.key, 'foo')
        self.assertEqual(field.label, 'Bar')

        updated_field = ContactField.update_or_create_from_temba(
            self.nigeria, temba_contact_field)

        self.assertEqual(field.pk, updated_field.pk)