447dcc9 Refactor MBS().get_modules to retrieve results per page params

Authored and Committed by qwan 4 years ago
    Refactor MBS().get_modules to retrieve results per page params
    
    Previously, we have 'auto_next_page' to control whether we should
    get items in all pages, when it's true, we get items from next page
    automatically, this param is not easy to understand and can result
    in many requests.get calls (one for each page).
    
    In this change, 'get_modules' is changed to get items per the
    'page' and 'per_page' params, when 'page' or 'per_page' or both
    of them is specified, we only get items from the page specified
    or with default value:
    
    1. Only 'page' is specified, get the items from the specified page,
    no 'per_page' specified when querying from MBS, so it will be the
    default value from MBS, which is 10.
    
    2. Only 'per_page' is specified, get the items from the first page,
    and query MBS with the specified 'per_page'.
    
    3. Both 'page' and 'per_pager' is specified, query MBS with the
    specified params.
    
    4. None of 'page' or 'per_page' is specified, we get items from all
    pages automatically, this is achieved by querying MBS without 'page'
    or 'per_page' first, and we will get 'total' number in result, then
    we query MBS again with 'per_page' = 'total'.
    
    And in this commit, changed 'make_mbs_response' for unittest. We
    can have two 'requests.get' calls in get_modules, the new
    MockMBSBuildsData().get can mock the 'requests.get' accordingly
    even there are multiple calls in our test function. And with
    MockMBSBuildsData().get, we don't need the test data of
    'test_data/mbs_modules_testmodule_page*.json' anymore.
    
        
file modified
+41 -32
file modified
+9 -7
file modified
+7 -5
file modified
+32 -47
file modified
+5 -4
file modified
+1 -2
file modified
+29 -37