Example #1
0
    def create_bulk_cases(self, mozwebqa, product, use_API, cases_amount=2, status='active', version=None, suite_name=None, **kwargs):
        if use_API:
            cases = []
            credentials = mozwebqa.credentials['default']
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
            for i in xrange(cases_amount):
                case = MockCase()
                if 'name' in kwargs:
                    case['name'] = kwargs['name']
                api.create_case(case, product)
                cases.append(case)
        else:
            create_bulk_cases_pg = MozTrapCreateBulkCasesPage(mozwebqa)

            if version is None:
                version = product['version']

            create_bulk_cases_pg.go_to_create_bulk_cases_page()
            cases = create_bulk_cases_pg.create_bulk_cases(
                product=product['name'], version=version['name'], status=status,
                suite=suite_name, cases_amount=cases_amount, **kwargs)

            #add product to dictionary to ensure that output of this method
            #is similar to create_case method
            for case in cases:
                case['product'] = product

        return cases
Example #2
0
def element(request):
    """Return an element with an embedded category created via the Moztrap API,
     and automatically delete them after the test."""
    mozwebqa = request.getfuncargvalue("mozwebqa")
    credentials = mozwebqa.credentials["default"]
    request.element = MockElement()
    api = MoztrapAPI(credentials["api_user"], credentials["api_key"], mozwebqa.base_url)
    api.create_element(request.element)

    return request.element
Example #3
0
def element(request):
    """Return an element with an embedded category created via the Moztrap API,
     and automatically delete them after the test."""
    mozwebqa = request.getfuncargvalue('mozwebqa')
    credentials = mozwebqa.credentials['default']
    request.element = MockElement()
    api = MoztrapAPI(credentials['api_user'], credentials['api_key'],
                     mozwebqa.base_url)
    api.create_element(request.element)

    return request.element
Example #4
0
def element(request):
    """Return an element with an embedded category created via the Moztrap API,
     and automatically delete them after the test."""
    mozwebqa = request.getfuncargvalue('mozwebqa')
    credentials = mozwebqa.credentials['default']
    request.element = MockElement()
    api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
    api.create_element(request.element)

    # The element and category cannot be deleted via the API at this point, likely because they
    # are still connected to something. This will be addressed in a future pull.

    return request.element
Example #5
0
def product(request):
    """Return a product created via the Moztrap API, and automatically delete the product after the test."""
    mozwebqa = request.getfuncargvalue('mozwebqa')
    credentials = mozwebqa.credentials['default']
    request.product = MockProduct()
    api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
    api.create_product(request.product)

    # This acts like a tearDown, running after each test function
    def fin():
        if hasattr(request, 'product'):
            api.delete_product(request.product)
    request.addfinalizer(fin)
    return request.product
Example #6
0
    def create_suite(self, mozwebqa, product, use_API, status='active', case_list=[], **kwargs):
        if use_API:
            credentials = mozwebqa.credentials['default']
            suite = MockSuite()
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
            api.create_suite(suite, product, case_list)
        else:
            create_suite_pg = MozTrapCreateSuitePage(mozwebqa)

            create_suite_pg.go_to_create_suite_page()
            suite = create_suite_pg.create_suite(product=product['name'], status=status, case_list=case_list, **kwargs)
            suite['product'] = product

        return suite
Example #7
0
    def create_case(self, mozwebqa, product, use_API, mock_case=None):
        if use_API:
            credentials = mozwebqa.credentials['default']
            case = MockCase()
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
            api.create_case(case, product)
        else:
            mock_case = mock_case or MockCase()
            mock_case['product'] = product
            mock_case['version'] = product['version']

            create_case_pg = MozTrapCreateCasePage(mozwebqa)
            create_case_pg.go_to_create_case_page()
            case = create_case_pg.create_case(mock_case)

        return case
Example #8
0
    def create_case(self,
                    mozwebqa,
                    product,
                    use_API,
                    status='active',
                    version=None,
                    suite_name=None):
        if use_API:
            credentials = mozwebqa.credentials['default']
            case = MockCase()
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'],
                             mozwebqa.base_url)
            api.create_case(case, product)
        else:
            create_case_pg = MozTrapCreateCasePage(mozwebqa)

            if version is None:
                version = product['version']

            create_case_pg.go_to_create_case_page()
            case = create_case_pg.create_case(product=product['name'],
                                              version=version['name'],
                                              status=status,
                                              suite=suite_name)
            case['product'] = product

        return case
Example #9
0
    def create_case(self, mozwebqa, product, use_API, status='active', version=None, suite_name=None):
        if use_API:
            credentials = mozwebqa.credentials['default']
            case = MockCase()
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
            api.create_case(case, product)
        else:
            create_case_pg = MozTrapCreateCasePage(mozwebqa)

            if version is None:
                version = product['version']

            create_case_pg.go_to_create_case_page()
            case = create_case_pg.create_case(product=product['name'], version=version['name'], status=status, suite=suite_name)
            case['product'] = product

        return case
Example #10
0
def product(request):
    """Return a product created via the Moztrap API, and automatically delete the product after the test."""
    mozwebqa = request.getfuncargvalue("mozwebqa")
    credentials = mozwebqa.credentials["default"]
    request.product = MockProduct()
    api = MoztrapAPI(credentials["api_user"], credentials["api_key"], mozwebqa.base_url)
    api.create_product(request.product)

    # This acts like a tearDown, running after each test function
    def fin():
        if hasattr(request, "product"):
            api.delete_product(request.product)
        # We have to add this here, rather than in a finalizer for the element fixture as the
        # Product has to be deleted first
        if hasattr(request, "element"):
            api.delete_element(request.element)

    request.addfinalizer(fin)
    return request.product
Example #11
0
def product(request):
    """Return a product created via the Moztrap API, and automatically delete the product after the test."""
    mozwebqa = request.getfuncargvalue('mozwebqa')
    credentials = mozwebqa.credentials['default']
    request.product = MockProduct()
    api = MoztrapAPI(credentials['api_user'], credentials['api_key'],
                     mozwebqa.base_url)
    api.create_product(request.product)

    # This acts like a tearDown, running after each test function
    def fin():
        if hasattr(request, 'product'):
            api.delete_product(request.product)
        # We have to add this here, rather than in a finalizer for the element fixture as the
        # Product has to be deleted first
        if hasattr(request, 'element'):
            api.delete_element(request.element)

    request.addfinalizer(fin)
    return request.product
Example #12
0
    def create_suite(self,
                     mozwebqa,
                     product,
                     use_API,
                     status='active',
                     case_list=[],
                     **kwargs):
        if use_API:
            credentials = mozwebqa.credentials['default']
            suite = MockSuite()
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'],
                             mozwebqa.base_url)
            api.create_suite(suite, product, case_list)
        else:
            create_suite_pg = MozTrapCreateSuitePage(mozwebqa)

            create_suite_pg.go_to_create_suite_page()
            suite = create_suite_pg.create_suite(product=product['name'],
                                                 status=status,
                                                 case_list=case_list,
                                                 **kwargs)
            suite['product'] = product

        return suite
Example #13
0
    def create_case(self, mozwebqa, product, use_API, mock_case=None):
        if use_API:
            credentials = mozwebqa.credentials['default']
            case = MockCase()
            api = MoztrapAPI(credentials['api_user'], credentials['api_key'],
                             mozwebqa.base_url)
            api.create_case(case, product)
        else:
            mock_case = mock_case or MockCase()
            mock_case['product'] = product
            mock_case['version'] = product['version']

            create_case_pg = MozTrapCreateCasePage(mozwebqa)
            create_case_pg.go_to_create_case_page()
            case = create_case_pg.create_case(mock_case)

        return case
Example #14
0
 def create_bulk_cases(self,
                       mozwebqa,
                       product,
                       use_API,
                       cases_amount=2,
                       status='active',
                       version=None,
                       suite_name=None,
                       **kwargs):
     if use_API:
         cases = []
         credentials = mozwebqa.credentials['default']
         api = MoztrapAPI(credentials['api_user'], credentials['api_key'],
                          mozwebqa.base_url)
         for i in xrange(cases_amount):
             case = MockCase()
             if 'name' in kwargs:
                 case['name'] = kwargs['name']
             api.create_case(case, product)
             cases.append(case)
Example #15
0
def api(request, base_url, variables):
    return MoztrapAPI(variables['api']['user'], variables['api']['key'], base_url)
Example #16
0
def api(request, variables):
    url = request.getfuncargvalue('mozwebqa').base_url
    return MoztrapAPI(variables['api']['user'], variables['api']['key'], url)