示例#1
0
    def _load_fixtures(self):
        """
        Create and save the necessary factories.
        """
        self.stdout.write("Attempting to load mysite fixtures...")

        author1 = AuthorFactory.create()
        author2 = AuthorFactory.create()
        BookFactory.create(authors=[author1, author2])

        self.stdout.write("Fixtures loaded successfully.")
示例#2
0
    def handle(self, *args, **options):

        num = options['num_books']
        print num
        Book.objects.all().delete()

        BookImage.objects.all().delete()

        for x in range(num):
            BookFactory.create()

        for book in Book.objects.all():
            BookImageFactory.create(book=book)
    def handle(self, *args, **options):

        num = options['num_books']
        print num
        Book.objects.all().delete()

        BookImage.objects.all().delete()

        for x in range(num):
            BookFactory.create()

        for book in Book.objects.all():
            BookImageFactory.create(book=book)
示例#4
0
    def test_retrieve(self):
        """
        Make sure that retrieve is working as expected.
        """
        book = BookFactory.create()
        self.view = BookViewSet.as_view({'get': 'retrieve'})

        url = "{0}{1}".format(BASE_URL, book.id)

        request = self.factory.get(url)

        response = self.view(request, pk=book.id)

        self.assertEqual(response.data['id'], book.id)