class StoryTests(SiteTestHelper, TestCase): def setUp(self): self.story = StoryFactory() def test_story_detail(self): self.assert_page_loads(self.story.get_absolute_url(), 'stories/single_detail.html') def test_story_returns_404_if_unpublished(self): story = StoryFactory(status='d') resp = self.client.get(story.get_absolute_url()) self.assertEqual(resp.status_code, 404)
def test_can_create_story(self): #story= #print (Story.objects.all().values()) story = StoryFactory.stub() ## make a user to associate with the story user_create=UserFactory.create() owner=User.objects.get(id=user_create.id) owner_url=reverse('user-detail', args=(owner.id,)) #self.data = {'name': 'My First Story', 'description': 'yourstory', 'instructions': 'put your dots on your maps and connect them with them lines', 'owner': owner} self.data = {'name': story.name, 'description': story.description, 'instructions': story.instructions, 'owner': owner_url} url = reverse('story-list') response = self.client.post(url, self.data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(Story.objects.count(), 1) self.assertEqual(Story.objects.get().name, str(story.name))
def setUp(self): self.story = StoryFactory()
def test_story_returns_404_if_unpublished(self): story = StoryFactory(status='d') resp = self.client.get(story.get_absolute_url()) self.assertEqual(resp.status_code, 404)