def test_create_post(self): p = Post( title="sample title", description="description", subtitle="subtitle", content="sample content", position=3 ) p.save() self.assertEquals(p.featured_in_category, False) self.assertEquals(Post.objects.all().count(), 1) self.assertEquals(self.workspace.S(eg_models.Page).count(), 1) p = Post.objects.get(pk=p.pk) p.title = "changed title" p.save() self.assertEquals(self.workspace.S(eg_models.Page).count(), 1) [eg_page] = self.workspace.S(eg_models.Page).everything() self.assertEquals(eg_page.title, "changed title") self.assertEquals(eg_page.uuid, p.uuid) self.assertEquals(eg_page.subtitle, "subtitle") self.assertEquals(eg_page.description, "description") self.assertEquals(eg_page.featured_in_category, False) self.assertEquals(eg_page.position, 3) self.assertTrue(eg_page.created_at is not None) self.assertTrue(eg_page.modified_at is not None) p.delete() self.assertEquals(Post.objects.all().count(), 0) self.assertEquals(self.workspace.S(eg_models.Page).count(), 0)
def test_page_recreated_if_not_in_git(self): with self.settings(GIT_REPO_PATH=self.workspace.working_dir): p = Post( title="sample test title", description="description", subtitle="subtitle", content="sample content" ) p.save() p = Post.objects.get(pk=p.pk) # Manually delete the git page [git_page] = self.workspace.S(eg_models.Page).filter(uuid=p.uuid) self.workspace.delete(git_page.get_object(), "Removing: %s" % p.uuid) self.workspace.refresh_index() self.assertEquals(self.workspace.S(eg_models.Page).filter(uuid=p.uuid).count(), 0) p.title = "new title" p.save() p = Post.objects.get(pk=p.pk) [git_p] = self.workspace.S(eg_models.Page).filter(uuid=p.uuid) self.assertEquals(git_p.title, "new title")