Ejemplo n.º 1
0
    def create_testplan_from_test_unit_id(self, test_unit_id):
        testunit_data = TestUnitAPI().get_testunit_form_data(
            id=test_unit_id)[0]['testUnit']
        if testunit_data['materialTypesObject'][0]['name'] == 'All':
            response, _ = GeneralUtilitiesAPI().list_all_material_types()
            _formatted_material = random.choice(response['materialTypes'])
        else:
            _formatted_material = testunit_data['materialTypesObject'][0]

        formatted_material = {
            'id': _formatted_material['id'],
            'text': _formatted_material['name']
        }

        # tu_response, tu_payload = TestUnitAPI().create_qualitative_testunit()
        testunit_data = TestUnitAPI().get_testunit_form_data(
            id=test_unit_id)[0]['testUnit']
        formated_testunit = TstUnit().map_testunit_to_testplan_format(
            testunit=testunit_data)
        formatted_article = ArticleAPI(
        ).get_formatted_article_with_formatted_material_type(
            formatted_material)
        testplan, payload = self.create_testplan(
            testUnits=[formated_testunit],
            selectedArticles=[formatted_article],
            materialType=[formatted_material],
            materialTypeId=[formatted_material['id']])

        if testplan['message'] == 'operation_success':
            return self.get_testplan_form_data(id=payload['number'])
        else:
            self.info(testplan)
Ejemplo n.º 2
0
    def create_double_completed_testplan_same_name_diff_material(
            self, **kwargs):
        self.info("create completed test plan with random data")
        testplan1 = self.create_completed_testplan_random_data()
        test_plan_name_dict = {
            'id': 'new',
            'text': testplan1['testPlan']['text']
        }
        new_material = random.choice(
            GeneralUtilitiesAPI().get_material_types_without_duplicate(
                testplan1['materialType'][0]['text']))
        new_material_id = GeneralUtilitiesAPI().get_material_id(new_material)
        formatted_material = {'id': new_material_id, 'text': new_material}
        tu_response, _ = TestUnitAPI().create_qualitative_testunit(
            selectedMaterialTypes=[formatted_material])
        testunit_data = TestUnitAPI().get_testunit_form_data(
            id=tu_response['testUnit']['testUnitId'])[0]['testUnit']
        formated_testunit = TstUnit().map_testunit_to_testplan_format(
            testunit=testunit_data)
        self.info(
            "create completed test plan with same name {} and new material {}".
            format(testplan1['testPlan']['text'], new_material))
        formatted_article = ArticleAPI(
        ).get_formatted_article_with_formatted_material_type(
            material_type=formatted_material)
        response, testplan2 = self.create_testplan(
            selectedTestPlan=test_plan_name_dict,
            testPlan=test_plan_name_dict,
            testUnits=[formated_testunit],
            selectedArticles=[formatted_article],
            materialType=[formatted_material],
            materialTypeId=[new_material_id])

        if response['message'] == 'name_already_exist':
            testplan2['testPlan']['id'] = response['testPlanDetails'][
                'testPlanId']
            testplan2['selectedTestPlan']['id'] = response['testPlanDetails'][
                'testPlanId']
            return [testplan1, testplan2]
        else:
            raise Exception(
                f'cant create the test plan with payload {testplan2}')
Ejemplo n.º 3
0
    def create_testplan_with_article_not_all(self):
        response, _ = GeneralUtilitiesAPI().list_all_material_types()
        formatted_material = random.choice(response['materialTypes'])

        formatted_article = ArticleAPI(
        ).get_formatted_article_with_formatted_material_type(
            formatted_material)
        testplan, payload = self.create_testplan(
            selectedArticles=[formatted_article],
            materialType=[formatted_material])
        if testplan['message'] == 'operation_success':
            return (self.get_testplan_form_data(id=payload['number']))
        else:
            raise Exception(
                f'cant create the test plan with payload {payload}')
Ejemplo n.º 4
0
    def get_article_with_material_type(self, material_type):
        material_type_id = GeneralUtilitiesAPI().get_material_id(material_type)
        articles, payload = self.get_all_articles(limit=500)
        self.info(
            "search for article with material type {}".format(material_type))
        for article in articles['articles']:
            if article['materialType'] == material_type:
                return article['name']

        self.info("No article with requested material type, So create article")
        materialType = {"id": material_type_id, "text": material_type}
        api, payload = self.create_article(
            materialType=materialType,
            selectedMaterialType=[materialType],
            materialTypeId=int(material_type_id))
        if api['status'] == 1:
            return api['article']['name']
Ejemplo n.º 5
0
    def create_completed_testplan(self, material_type, formatted_article):
        material_type_id = GeneralUtilitiesAPI().get_material_id(material_type)
        formatted_material = {'id': material_type_id, 'text': material_type}
        tu_response, tu_payload = TestUnitAPI().create_qualitative_testunit()
        testunit_data = TestUnitAPI().get_testunit_form_data(
            id=tu_response['testUnit']['testUnitId'])[0]['testUnit']
        formated_testunit = TstUnit().map_testunit_to_testplan_format(
            testunit=testunit_data)
        testplan, payload = self.create_testplan(
            testUnits=[formated_testunit],
            selectedArticles=[formatted_article],
            materialType=[formatted_material],
            material_type_id=material_type_id)

        if testplan['message'] == 'operation_success':
            return self.get_testplan_form_data(
                id=int(testplan['testPlanDetails']['id']))
        else:
            self.info(testplan)
Ejemplo n.º 6
0
 def create_testplan_with_multiple_materials(self, no_materials=3):
     all_material_types = GeneralUtilitiesAPI().list_all_material_types(
     )[0]['materialTypes']
     formatted_materials = random.sample(all_material_types, no_materials)
     material_type_ids = [
         material['id'] for material in formatted_materials
     ]
     selected_material_types = [
         material['name'] for material in formatted_materials
     ]
     tu_response, _ = TestUnitAPI().create_quantitative_testunit(
         selectedMaterialTypes=formatted_materials[0])
     testunit_data = TestUnitAPI().get_testunit_form_data(
         id=tu_response['testUnit']['testUnitId'])[0]['testUnit']
     formatted_testunit = TstUnit().map_testunit_to_testplan_format(
         testunit=testunit_data)
     testplan = self.create_testplan(testUnits=[formatted_testunit],
                                     materialType=formatted_materials,
                                     materialTypeId=material_type_ids)
     return testplan[1]['testPlan']['text'], selected_material_types
Ejemplo n.º 7
0
 def get_suborder_data_with_different_material_type(self, material_type):
     new_material = random.choice(GeneralUtilitiesAPI(
     ).get_formatted_material_types_without_duplicate(material_type))
     formatted_material = {
         'id': new_material['id'],
         'text': new_material['name']
     }
     formatted_article = ArticleAPI(
     ).get_formatted_article_with_formatted_material_type(
         material_type=formatted_material)
     test_plan_data = self.create_completed_testplan(
         material_type=new_material['name'],
         formatted_article=formatted_article)
     created_data = {
         'test_plan': test_plan_data['testPlanEntity']['name'],
         'test_unit': test_plan_data['specifications'][0]['name'],
         'material_type': new_material['name'],
         'article': formatted_article['name']
     }
     return created_data
 def setUp(self):
     super().setUp()
     self.order_page = Order()
     self.suborder_table = SubOrders()
     self.orders_api = OrdersAPI()
     self.orders_page = Orders()
     self.analyses_page = AllAnalysesPage()
     self.contacts_api = ContactsAPI()
     self.test_unit_api = TestUnitAPI()
     self.test_plan_api = TestPlanAPI()
     self.general_utilities = GeneralUtilitiesAPI()
     self.set_authorization(auth=BaseAPI().AUTHORIZATION_RESPONSE)
     self.test_unit_api.set_name_configuration_name_only()
     self.orders_api.set_configuration()
     self.header_page = Header()
     article_enabled = self.general_utilities.is_article_enabled()
     if article_enabled:
         self.info('go to Modules Configurations')
         self.header_page.get_modules_config_page()
         self.header_page.disable_article_option()
     self.header_page.sleep_tiny()
     self.order_page.get_orders_page()
Ejemplo n.º 9
0
    def create_completed_testplan_random_data(self, no_testunits=1):
        random_article = random.choice(ArticleAPI().get_all_articles_json())
        formatted_article = {
            'id': random_article['id'],
            'text': random_article['name']
        }
        material_type_id = GeneralUtilitiesAPI().get_material_id(
            random_article['materialType'])
        formatted_material = {
            'id': material_type_id,
            'text': random_article['materialType']
        }
        # creates test unit with values in it
        formatted_testunits = []
        for testunit in range(no_testunits):
            tu_response, _ = TestUnitAPI().create_quantitative_testunit(
                selectedMaterialTypes=[formatted_material])
            testunit_data = TestUnitAPI().get_testunit_form_data(
                id=tu_response['testUnit']['testUnitId'])[0]['testUnit']
            formatted_testunit = TstUnit().map_testunit_to_testplan_format(
                testunit=testunit_data)
            formatted_testunits.append(formatted_testunit)

        testplan, payload = self.create_testplan(
            testUnits=formatted_testunits,
            selectedArticles=[formatted_article],
            materialType=[formatted_material],
            materialTypeId=[material_type_id])

        if testplan['message'] == 'operation_success':
            payload['testPlan']['id'] = testplan['testPlanDetails'][
                'testPlanId']
            payload['selectedTestPlan']['id'] = testplan['testPlanDetails'][
                'testPlanId']
            return payload
        else:
            return None