def setUp(self): super().setUp() # Create a custom field on the Site model ct = ContentType.objects.get_for_model(Site) cf = CustomField(type=CustomFieldTypeChoices.TYPE_TEXT, name='my_field', required=False) cf.save() cf.content_types.set([ct]) # Create a select custom field on the Site model cf_select = CustomField(type=CustomFieldTypeChoices.TYPE_SELECT, name='my_field_select', required=False, choices=['Bar', 'Foo']) cf_select.save() cf_select.content_types.set([ct]) # Create some tags tags = ( Tag(name='Tag 1', slug='tag-1'), Tag(name='Tag 2', slug='tag-2'), Tag(name='Tag 3', slug='tag-3'), ) Tag.objects.bulk_create(tags)
def setUpTestData(cls): Tag.objects.bulk_create(( Tag(name='Tag 1', slug='tag-1'), Tag(name='Tag 2', slug='tag-2'), Tag(name='Tag 3', slug='tag-3'), )) cls.form_data = { 'name': 'Tag X', 'slug': 'tag-x', 'color': 'c0c0c0', 'comments': 'Some comments', } cls.csv_data = ( "name,slug,color,description", "Tag 4,tag-4,ff0000,Fourth tag", "Tag 5,tag-5,00ff00,Fifth tag", "Tag 6,tag-6,0000ff,Sixth tag", ) cls.bulk_edit_data = { 'color': '00ff00', }
def setUpTestData(cls): tags = ( Tag(name='Tag 1', slug='tag-1'), Tag(name='Tag 2', slug='tag-2'), Tag(name='Tag 3', slug='tag-3'), ) Tag.objects.bulk_create(tags)
def setUp(self): user = create_test_user(permissions=['extras.view_tag']) self.client = Client() self.client.force_login(user) Tag.objects.bulk_create([ Tag(name='Tag 1', slug='tag-1'), Tag(name='Tag 2', slug='tag-2'), Tag(name='Tag 3', slug='tag-3'), ])
def create_tags(*names): """ Create and return a Tag instance for each name given. """ tags = [Tag(name=name, slug=slugify(name)) for name in names] Tag.objects.bulk_create(tags) return tags
def setUpTestData(cls): Tag.objects.bulk_create(( Tag(name='Tag 1', slug='tag-1'), Tag(name='Tag 2', slug='tag-2'), Tag(name='Tag 3', slug='tag-3'), )) cls.form_data = { 'name': 'Tag X', 'slug': 'tag-x', 'color': 'c0c0c0', 'comments': 'Some comments', } cls.bulk_edit_data = { 'color': '00ff00', }
def setUpTestData(cls): site_ct = ContentType.objects.get_for_model(Site) DUMMY_URL = "http://localhost/" DUMMY_SECRET = "LOOKATMEIMASECRETSTRING" webhooks = Webhook.objects.bulk_create(( Webhook(name='Webhook 1', type_create=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET, additional_headers='X-Foo: Bar'), Webhook(name='Webhook 2', type_update=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET), Webhook(name='Webhook 3', type_delete=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET), )) for webhook in webhooks: webhook.content_types.set([site_ct]) Tag.objects.bulk_create(( Tag(name='Foo', slug='foo'), Tag(name='Bar', slug='bar'), Tag(name='Baz', slug='baz'), ))
def test_create_tag_unicode(self): tag = Tag(name='Testing Unicode: 台灣') tag.save() self.assertEqual(tag.slug, 'testing-unicode-台灣')