Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:57:12+00:00 2026-05-23T14:57:12+00:00

We have this view that look something like this: from fblib import Facebook def

  • 0

We have this view that look something like this:

from fblib import Facebook

def foo(request):
    fb = Facebook( settings.facebook )
    data = fb.get_thingy()
    return render_to_response( .. , data, .. )

What would be a good way of testing that? Since the view fetches the resource by itself I’m unsure how I could mock Facebook. One alternative in my mind is to create a fake Facebook server and supply the connection details in the settings. So we get a unittest that look something like this:

from fakebook import FakeFacebookServer

class ViewsFooTests(TestCase):
    def set_up( self ):
        self.facebook = FakeFacebookServer().start()

    def test_foo_connect( self ):
        response = self.client.get('/foo')
        self.assertEquals( response.status_code, 200 )

The issue I have with the that is that it seem like making a fake Facebook server seem like a lot of hassle. Ideally I would rather be able to mock the Facebook.get_thingy method. Suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:57:13+00:00Added an answer on May 23, 2026 at 2:57 pm

    You can modify your views module from your tests for mocking your library:

    # tests.py
    import myapp.views
    ...
    
        def setUp(self):
            myapp.views.Facebook = FaceBookMock
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View that renders something like this: Item 1 and Item 2
I have views which look something like this: mysql> select * from p2; +---+---------+---------+
I have a large table that get populated from a view. This is done
I have an app that displays transcripts, something like this myapp.com/transcript/1234 The transcripts are
I currently have page-specific javascript files that look something like: $(document).ready(function () { namespace.home.list
I have a hypothetical tree view that contains this data: RootNode Leaf vein SecondRoot
I have this method in App Delegate that makes a window and content view
I have this layout that works correctly, a relative layout with a text view
So I have this page that has some basic custom tabs: http://demo.unlockedmanagement.com/users/view/2 * NOTE
I know this is extremely silly. I have a view controller that scans a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.