def test_returns_200(self, rf, admin_user):
        DonorFactory()

        request = rf.get('/')
        request.user = admin_user

        response = admin_views.print_view(request, 'accession', 'donor', 1)

        assert response.status_code == 200
    def test_returns_200(self, rf, admin_user):
        DonorFactory()

        request = rf.get('/')
        request.user = admin_user

        response = admin_views.print_view(request, 'accession', 'donor', 1)

        assert response.status_code == 200
    def test_correct_info_printed(self, rf, admin_user):
        accession = AccessionFactory()

        request = rf.get('/')
        request.user = admin_user

        response = admin_views.print_view(request, 'accession', 'accession', 1)

        # Check a couple fields to make sure they're there.
        assert accession.description in response.content
        assert accession.acquisition_method in response.content
        # Make sure the related items are there too.
        assert str(accession.donor) in response.content
    def test_correct_info_printed(self, rf, admin_user):
        accession = AccessionFactory()

        request = rf.get('/')
        request.user = admin_user

        response = admin_views.print_view(request, 'accession', 'accession', 1)

        # Check a couple fields to make sure they're there.
        assert accession.description in response.content.decode()
        assert accession.acquisition_method in response.content.decode()
        # Make sure the related items are there too.
        assert str(accession.donor) in response.content.decode()
    def test_raises_404_when_object_id_not_found(self, rf, admin_user):
        request = rf.get('/')
        request.user = admin_user

        with pytest.raises(Http404):
            admin_views.print_view(request, 'accession', 'donor', 8)
    def test_raises_404_when_model_does_not_exist(self, rf, admin_user):
        request = rf.get('/')
        request.user = admin_user

        with pytest.raises(Http404):
            admin_views.print_view(request, 'accession', 'dne', 1)
    def test_raises_404_when_object_id_not_found(self, rf, admin_user):
        request = rf.get('/')
        request.user = admin_user

        with pytest.raises(Http404):
            admin_views.print_view(request, 'accession', 'donor', 8)
    def test_raises_404_when_model_does_not_exist(self, rf, admin_user):
        request = rf.get('/')
        request.user = admin_user

        with pytest.raises(Http404):
            admin_views.print_view(request, 'accession', 'dne', 1)