root_page = Page.objects.get(depth=1) # there is always One Root Page at the top of the tree
home_page = HomePage(title="Home", body="Foo") # Create a new page in memory, it's not saved yet
home_page.baz = "Bar" # we can assign properties, don't need to stuff everything into the constructor
root_page.add_child(home_page) # Treebeard API call saves it to the database and sets the path appropriately
home_page.save_revision().publish() # Appease the Wagtail page revision gods, I always do this superstitiously| def test_create_simplepage(self): | |
| response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id))) | |
| self.assertEqual(response.status_code, 200) | |
| self.assertContains(response, '<a href="#content" class="active">Content</a>') | |
| self.assertContains(response, '<a href="#promote" class="">Promote</a>') |
We have Selenium working now which was a bit tricky inside vagrant, one simple test, the next step is to use it to add a wagtail page, currently it just tests a search form.
I will post details of how it goes soon hopefully.
Joss
| <input id="id_chunk_items-__prefix__-chunk_title" maxlength="255" name="chunk_items-__prefix__-chunk_title" type="text" /> |
I have got a few basic tests running using normal django unit tests and Selenium. The plan is to build them up as we go, will probably document some of the more esoteric Selenium / wagtail UI bits in a blog post soon.
Thanks for your past help btw