Module ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str TryExcept body Return SubscriptLoad NameLoad Index NameLoad handlers ExceptHandler type NameLoad body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad BinOpMod Str TupleLoad NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot CompareIn NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body TryExcept body Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Assign NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad Num Dict Assign NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad Num NameLoad Assign NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad Num NameLoad Assign NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad Num NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr Str If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad orelse Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Dict For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Assign NameStore Dict Assign NameStore Call NameLoad NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Dict NameLoad NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Dict NameLoad NameLoad Return NameLoad decorator_list Assign NameStore ListLoad Str Str Str Str Str Str Str Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Return BinOpMod Str TupleLoad Call NameLoad NameLoad BinOpAdd Call AttributeLoad NameLoad attr NameLoad Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Num NameLoad body Expr Str Assign NameStore ListLoad Assign NameStore Call AttributeLoad NameLoad attr For TupleStore NameStore NameStore Call NameLoad NameLoad body If CompareIn NameLoad NameLoad body Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore IfExp CompareGtE NameLoad Num NameLoad Num Assign NameStore Call AttributeLoad Str attr SubscriptLoad NameLoad Slice NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore IfExp CompareLtE BinOpAdd BinOpAdd NameLoad Num NameLoad NameLoad BinOpAdd BinOpAdd NameLoad Num NameLoad NameLoad Assign NameStore Call AttributeLoad Str attr SubscriptLoad NameLoad Slice BinOpAdd NameLoad Num NameLoad Assign NameStore BinOpMod Str Dict Str Str Str IfExp NameLoad BinOpAdd NameLoad Str Str IfExp NameLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad IfExp NameLoad BinOpAdd Str NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Num body Expr Str Assign NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad Str Print BinOpAdd BinOpAdd Str Call AttributeLoad Str attr NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Import alias alias alias With Call AttributeLoad NameLoad attr NameStore body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If NameLoad body Expr Call NameLoad Str orelse Expr Call AttributeLoad NameLoad attr Num decorator_list
N/A transifex.txcommon.tests.base USER_ROLES transifex.txcommon.log logger getitem N/A N/A list index default N/A None N/A N/A 
    Return a value from a 'list' for the given 'index' or the 'default' value.
     N/A N/A N/A N/A list N/A index N/A N/A N/A IndexError N/A N/A default N/A assert_status_code N/A N/A unittest response expected_code url user_role N/A N/A N/A N/A N/A unittest assertEqual N/A response status_code expected_code N/A Status code for page '%s' was %s instead of %s for the '%s' user role. 
%s N/A url N/A response status_code expected_code user_role response N/A check_page_status N/A N/A unittest user_role url_roles N/A N/A N/A 
    Check if each URL set in 'url_roles' match its status_code with the
    response code status depending on the user role. Each URL can be added to
    the 'url_roles' dictionary using a predefined structure of data.

    unittest - It's a instance of a class that inherits
        txcommon.tests.base.BaseTestCase.
    user_role - One of the user roles allowed on
        txcommon.tests.base.BaseTestCase.
    url_roles - A structured dictionary containing the url to be tested.

    Structure of 'url_roles':
        url_roles = {'<REQUEST_METHOD>:<URL>':{
            '<USER_ROLE>':(<STATUS_CODE>, <DICT_OF_ARGS>,
                <EXPECTED_CONTENTS>, <UNEXPECTED_CONTENTS>, <FOLLOW_REDIRECT>),
            (...)
            },
        }

        <REQUEST_METHOD> - Might be 'GET' or 'POST'.
        <URL> - The url that must be tested.
        <USER_ROLE> - One of the user roles allowed on
            txcommon.tests.base.BaseTestCase. At least one user
            role is required.
        <STATUS_CODE> - Code of status for the HTTP response.
        <DICT_OF_ARGS> - Arguments that might be passed to the HTTP request.
            Not required.
        <EXPECTED_CONTENTS> - A string that might be found using
            assertContains on the response contents. Not required.
        <UNEXPECTED_CONTENTS> - A string that shouldn't be found. Not required.
        <FOLLOW_REDIRECT> - If it's a redirect, follow it

    Know issues:
        <EXPECTED_CONTENTS> usually does not work with the status code 302.
     N/A N/A N/A user_role USER_ROLES N/A N/A N/A N/A unittest fail N/A Unknown user role: '%s' user_role N/A N/A url date_dict N/A N/A url_roles items N/A N/A N/A N/A expected_code N/A N/A date_dict N/A user_role N/A 0 N/A args N/A getitem N/A date_dict N/A user_role 1 N/A N/A expected_contents N/A getitem N/A date_dict N/A user_role 2 None N/A unexpected_contents N/A getitem N/A date_dict N/A user_role 3 None N/A follow_redirect N/A getitem N/A date_dict N/A user_role 4 False N/A client N/A N/A unittest client N/A user_role N/A N/A method url N/A tuple N/A N/A url split : N/A N/A method GET N/A N/A response N/A N/A client get url args follow follow_redirect N/A N/A N/A method POST N/A N/A response N/A N/A client post url args follow follow_redirect N/A N/A N/A N/A unittest fail N/A Unknown method request: '%s' role N/A N/A assert_status_code unittest response expected_code url user_role N/A expected_contents N/A N/A N/A N/A unittest assertContains response expected_contents status_code expected_code N/A unexpected_contents N/A N/A N/A N/A unittest assertNotContains response unexpected_contents status_code expected_code N/A N/A N/A KeyError N/A N/A N/A N/A logger info N/A User role '%s' not defined for the '%s' URL. N/A user_role url N/A convert_url_roles N/A N/A url_with_roles_as_key N/A N/A N/A 
    Convert url roles from a dictionary using the roles as the key to a
    dictionary using the url as key.

    'url_with_roles_as_key' is a dict in the following format:

    url_with_roles_as_key = {
        '(301, )':[
            'GET:/projects/p/project1/access/pm/add',
        ],
        '(200, {}, "Translation Teams Off")':[
            'GET:/projects/p/project1/teams/',
        ],
    }

    Output:
        {'GET:/projects/p/project1/access/pm/add': {
            'anonymous': (301,),
            'maintainer': (301,),
            'registered': (301,),
            'team_coordinator': (301,),
            'team_member': (301,),
            'writer': (301,)},
        'GET:/projects/p/project1/teams/': {
            'anonymous': (200, {}, 'Translation Teams Off'),
            'maintainer': (200, {}, 'Translation Teams Off'),
            'registered': (200, {}, 'Translation Teams Off'),
            'team_coordinator': (200, {}, 'Translation Teams Off'),
            'team_member': (200, {}, 'Translation Teams Off'),
            'writer': (200, {}, 'Translation Teams Off')}}
        }
     N/A url_keys N/A N/A N/A url_role urls N/A N/A url_with_roles_as_key items N/A N/A user_roles_dict N/A N/A url_role N/A eval url_role N/A user_role USER_ROLES N/A N/A N/A N/A user_roles_dict update N/A user_role url_role N/A url urls N/A N/A N/A N/A url_keys update N/A url user_roles_dict N/A url_keys N/A N/A COLORS N/A BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE color_text N/A N/A text color_name bold N/A False N/A N/A 
    This command can be used to colorify command line output. If the shell
    doesn't support this or the --disable-colors options has been set, it just
    returns the plain text.

    Usage:
        print "%s" % color_text("This text is red", "RED")
     N/A N/A [%s;%sm%s[0m N/A N/A int bold N/A N/A N/A COLORS index color_name 30 text N/A grep N/A N/A haystack needle ln color N/A 0 None N/A N/A Highlight needle in haystack and return a few lines around it.

    Mimic UNIX's grep method. Search for a string (needle) in a text chunk
    (haystack).

    Return a list of matches. Each match will have ln number of lines
    before and after it (similar to "grep -C NUM"). The matching line will be
    highlighted with a color from a pre-defined list.

    Examples:

    >>> grep('a
b
a1
a2
a3', 'b', 0)
    ['b']
    >>> grep('a
b
a1
a2
a3', 'b', 1)
    ['a
b
a1']
    >>> grep('a
b
a1
a2
a3', 'b', 3)
    ['a
b
a1
a2
a3']
    >>> grep('a
b
a1
a2
a3', 'b', 3, 'RED')
    ['a
[0;31mb[0m
a1
a2
a3']
    >>> grep('a
b
a1
a2
a3', 'a')
    ['a', 'a1', 'a2', 'a3']
    >>> grep('a
b
a1
a2
a3', 'a', 1)
    ['a
b', 'b
a1
a2', 'a1
a2
a3', 'a2
a3']

     N/A ret N/A N/A lines N/A N/A haystack split N/A N/A i line N/A enumerate lines N/A N/A N/A needle line N/A N/A first_possible N/A i ln N/A start N/A N/A first_possible 0 first_possible 0 N/A before N/A N/A join N/A lines N/A start i N/A last_possible N/A len lines N/A end N/A N/A N/A N/A i 1 ln last_possible N/A N/A i 1 ln last_possible N/A after N/A N/A join N/A lines N/A N/A i 1 end N/A txt N/A %(before)s%(match)s%(after)s N/A before match after N/A before N/A before N/A color N/A color_text N/A lines N/A i color N/A lines N/A i N/A after N/A after N/A N/A N/A ret append txt N/A ret N/A highlight_grep N/A N/A resp text context N/A 2 N/A N/A Highlight matches of text in response.content and print them.

    Particularly useful in tests with the django client to find some string
    in the response body. For example::

    >>> from txcommon.tests.utils import highlight_grep
    >>> resp = self.client.get(reverse('myUrlName', args=['foo']))
    >>> highlight_grep("SearchMe!")
     N/A res N/A grep N/A resp content text context RED N/A N/A N/A 
===== Matches =====================================
 N/A N/A 
---------------------------------------------------
 join res 
===================================================
 N/A response_in_browser N/A N/A resp halt N/A True N/A N/A Open a browser and render the response's content.

    Use it in tests to visually present the response and find what you need
    with your browser's super tools such as 'View Source' and 'Inspect Element'.

    The browser will not render static media (e.g. CSS). To achieve this, run
    a separate Django server and setup your static serving variable to an
    absolute URI (e.g. STATIC_URL = 'http://localhost:8000/site_media/).
    This will trick the temporary window to show the test's HTML with the
    static files served from the server.

    Call it as follows::

    >>> from txcommon.tests.utils import response_in_browser
    >>> resp = self.client.get(reverse('myUrlName', args=['foo']))
    >>> response_in_browser(resp)

    More info http://miniblog.glezos.com/post/3388080372/tests-browser

     N/A tempfile webbrowser time N/A N/A N/A tempfile NamedTemporaryFile f N/A N/A N/A N/A f write N/A resp content N/A N/A N/A f flush N/A N/A N/A webbrowser open N/A f name N/A halt N/A N/A N/A raw_input Press a key to continue with your tests... N/A N/A N/A N/A time sleep 1 N/A