示例#1
0
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)
示例#2
0
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)
示例#3
0
    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))
示例#4
0
 def setUp(self):
     self.story = StoryFactory()
示例#5
0
 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)
示例#6
0
 def setUp(self):
     self.story = StoryFactory()
示例#7
0
 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)