Skip to content

Commit

Permalink
Add test for posting to airtable_import_listing
Browse files Browse the repository at this point in the history
  • Loading branch information
gasman committed Dec 12, 2024
1 parent c5674b8 commit 971c88d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class TestAdminViews(TestCase):
fixtures = ['test.json']

def setUp(self):
airtable_patcher = patch("wagtail_airtable.mixins.Airtable", new_callable=get_mock_airtable())
airtable_patcher.start()
self.addCleanup(airtable_patcher.stop)
airtable_mixins_patcher = patch("wagtail_airtable.mixins.Airtable", new_callable=get_mock_airtable())
airtable_mixins_patcher.start()
self.addCleanup(airtable_mixins_patcher.stop)
airtable_importer_patcher = patch("wagtail_airtable.importer.Airtable", new_callable=get_mock_airtable())
self.mock_airtable = airtable_importer_patcher.start()
self.addCleanup(airtable_importer_patcher.stop)

self.client.login(username='admin', password='password')

Expand All @@ -24,6 +27,18 @@ def test_get(self):
self.assertContains(response, 'Advert')
self.assertNotContains(response, 'Simple Page')

def test_post(self):
advert = Advert.objects.get(airtable_record_id="recNewRecordId")
self.assertNotEqual(advert.title, "Red! It's the new blue!")

response = self.client.post(reverse('airtable_import_listing'), {
'model': 'tests.Advert',
})
self.assertRedirects(response, reverse('airtable_import_listing'))

advert.refresh_from_db()
self.assertEqual(advert.title, "Red! It's the new blue!")

def test_list_snippets(self):
url = reverse('wagtailsnippets_tests_advert:list')

Expand Down

0 comments on commit 971c88d

Please sign in to comment.