コード例 #1
0
    def test014_archived_testplan_shouldnot_appear_in_order(self):
        """
        In case a testplan is archived, it shouldn't appear when creating a new order

        LIMS-3708
        """
        self.info("navigate to orders page")
        self.order_page = Order()
        self.info("get random archived testplan")
        response, payload = self.test_plan_api.get_all_test_plans()
        self.assertEqual(response['status'], 1, payload)
        archived_test_plan = random.choice(response['testPlans'])
        self.test_plan_api.archive_testplans(
            ids=[str(archived_test_plan['id'])])
        self.order_page.get_orders_page()

        self.info("archived test plan data {}".format(archived_test_plan))
        self.info(
            "create a new order with material type and article of archived testplan"
        )
        if archived_test_plan['article'] != ['all']:
            self.order_page.create_new_order(
                material_type=archived_test_plan['materialTypes'][0],
                article=archived_test_plan['article'][0],
                test_plans=[archived_test_plan['testPlanName']])
        else:
            self.order_page.create_new_order(
                material_type=archived_test_plan['materialTypes'][0],
                test_plans=[archived_test_plan['testPlanName']])
        order_data = self.order_page.get_suborder_data()
        self.info(
            "get the first suborder's testplan and make sure it's an empty string"
        )
        self.assertCountEqual(order_data['suborders'][0]['testplans'], [''])
コード例 #2
0
 def setUp(self):
     super().setUp()
     self.login_page = Login()
     self.article_page = Article()
     self.test_plan = TstPlan()
     self.order = Order()
     self.login_page.login(username=self.base_selenium.username,
                           password=self.base_selenium.password)
     self.base_selenium.wait_until_page_url_has(text='dashboard')
     self.article_page.get_article_page()
コード例 #3
0
 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.test_unit_api = TestUnitAPI()
     self.test_units_page = TstUnits()
     self.my_profile_page = MyProfile()
     self.set_authorization(auth=BaseAPI().AUTHORIZATION_RESPONSE)
     self.test_unit_api.set_name_configuration_name_only()
     self.orders_api.set_configuration()
     self.order_page.get_orders_page()
     self.selected_language = 'EN'
    def test015_create_role_with_sample_management_permissions_then_create_user_by_it(self):
        """
        Roles & Permissions: when I create user with sample management permissions then create
        user wit it when I login with this user the master data only should appear in the menu

        LIMS-6441
        """
        self.login_page = Login()
        self.info("create role with random name with sample management permissions")
        random_role_name = self.generate_random_string()
        self.header_page.create_role_with_sample_management_permissions(role_name=random_role_name)

        self.info('go to the user section to create user with this role')
        self.header_page.get_users_page()
        random_user_name = self.generate_random_string()
        random_user_email = self.header_page.generate_random_email()
        random_user_password = self.generate_random_string()
        self.header_page.create_new_user(user_name=random_user_name,
                                         user_email=random_user_email,
                                         user_role=random_role_name,
                                         user_password=random_user_password,
                                         user_confirm_password=random_user_password)

        self.login_page.logout()

        self.info('login with role & user {}:{}'.format(random_user_name, random_user_password))
        self.login_page.login(username=random_user_name, password=random_user_password)
        self.header_page.sleep_medium()
        self.info('get the order url')
        self.assertTrue('Sample Management', Order().get_orders_page())
        self.info('get the analysis url')
        Orders().navigate_to_analysis_active_table()
        self.assertIn('sample/analysis', self.base_selenium.get_url())
コード例 #5
0
 def setUp(self):
     super().setUp()
     self.article_page = Article()
     self.article_api = ArticleAPI()
     self.test_plan_api = TestPlanAPI()
     self.test_plans_page = TestPlans()
     self.test_plan_page = TstPlan()
     self.orders_page = Orders()
     self.order_api = OrdersAPI()
     self.order_page = Order()
     self.set_authorization(auth=self.article_api.AUTHORIZATION_RESPONSE)
     self.article_api.set_configuration()
     self.article_page.get_articles_page()
 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()
コード例 #7
0
class OrdersExtendedTestCases(BaseTest):
    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.test_unit_api = TestUnitAPI()
        self.test_units_page = TstUnits()
        self.my_profile_page = MyProfile()
        self.set_authorization(auth=BaseAPI().AUTHORIZATION_RESPONSE)
        self.test_unit_api.set_name_configuration_name_only()
        self.orders_api.set_configuration()
        self.order_page.get_orders_page()
        self.selected_language = 'EN'

    def tearDown(self):
        if self.selected_language == 'DE':
            self.my_profile_page.get_my_profile_page()
            self.my_profile_page.chang_lang(lang='EN')
        return super().tearDown()

    @parameterized.expand(['EN', 'DE'])
    @attr(series=True)
    def test001_new_fields_are_displayed_in_order_child_table(self, lang):
        """
        Orders : child table: check that new fields of "Forwarding" , "Report sent by", "validation date" and
        "validation by"have been added to order's child table in both EN and DE

        LIMS-7714
        LIMS-7715
        """
        if lang == 'EN':
            required_headers = [
                'Forwarding', 'Report sent by', 'Validation by',
                'Validation date'
            ]
        else:
            self.selected_language = 'DE'
            self.my_profile_page.get_my_profile_page()
            self.my_profile_page.chang_lang(lang='DE')
            self.orders_page.get_orders_page()
            required_headers = [
                'Versand', 'Bericht Versand duch', 'Probenfreigabe Datum',
                'Probenfreigabe durch'
            ]

        self.orders_page.open_child_table(self.orders_page.result_table()[0])
        header_row = self.base_selenium.get_table_head_elements(
            element='general:table_child')
        displayed_child_headers = [h.text for h in header_row]
        displayed_Configuration_headers = self.orders_page.navigate_to_child_table_configuration(
        )
        for header in required_headers:
            self.info('asserting {} is displayed '.format(header))
            self.assertIn(header, displayed_child_headers)
            self.assertIn(header, displayed_Configuration_headers)

    @attr(series=True)
    def test002_check_validation_date_validation_by(self):
        """
         Orders: Validation date & Validation by : check that when user update the validation date &
         the validation by, the update should reflect on order's child table

         LIMS-7729
        """
        today = date.today()
        current_date = today.strftime("%d.%m.%Y")
        self.info('Calling the users api to create a new user with username')
        response, payload = UsersAPI().create_new_user()
        self.assertEqual(response['status'], 1, payload)
        self.single_analysis_page = SingleAnalysisPage()
        self.login_page = Login()
        self.info(
            "create new order and update its validation option to be conform")
        order_response, order_payload = self.orders_api.create_new_order()
        self.assertEqual(order_response['status'], 1, order_payload)
        order_no = order_payload[0]['orderNo']
        self.info('edit order with No {}'.format(order_no))
        self.orders_page.get_order_edit_page_by_id(
            order_response['order']['mainOrderId'])
        self.order_page.sleep_small()
        self.info('navigate to analysis tab')
        self.order_page.navigate_to_analysis_tab()
        self.order_page.sleep_tiny()
        self.single_analysis_page.set_testunit_values()
        self.order_page.sleep_tiny()
        self.info('change validation options to conform')
        self.single_analysis_page.change_validation_options(text='Conform')
        self.order_page.get_orders_page()
        self.order_page.sleep_tiny()
        self.orders_page.filter_by_order_no(filter_text=order_no)
        self.assertEqual(len(self.orders_page.result_table()) - 1, 1)
        suborders_data = self.order_page.get_child_table_data(index=0)
        self.info('assert validation by is set correctly')
        self.assertEqual(suborders_data[0]['Validation by'],
                         self.base_selenium.username)
        self.assertEqual(suborders_data[0]['Validation date'], current_date)
        self.info(
            'go to analysis table and assert validation by and validation options'
            ' are set correctly as in order active table')
        self.orders_page.navigate_to_analysis_active_table()
        self.analyses_page.filter_by_analysis_number(
            suborders_data[0]['Analysis No.'])
        analysis_data = self.analyses_page.get_the_latest_row_data()
        self.assertEqual(suborders_data[0]['Validation by'],
                         analysis_data['Validation by'])
        self.assertEqual(suborders_data[0]['Validation date'],
                         analysis_data['Validation date'])
        self.info("Logout then login again using new user {}".format(
            payload['username']))
        self.login_page.logout()
        self.login_page.login(username=payload['username'],
                              password=payload['password'])
        self.base_selenium.wait_until_page_url_has(text='dashboard')
        self.orders_page.get_order_edit_page_by_id(
            order_response['order']['mainOrderId'])
        self.info(
            'change validation options so validation by is changed to {}',
            payload['username'])
        self.order_page.navigate_to_analysis_tab()
        self.single_analysis_page.change_validation_options(text='Approved')
        self.orders_page.get_orders_page()
        self.orders_page.filter_by_order_no(filter_text=order_no)
        suborders_after = self.order_page.get_child_table_data(index=0)
        self.assertEqual(suborders_after[0]['Validation by'],
                         payload['username'])
        self.assertEqual(suborders_after[0]['Validation date'], current_date)

    @attr(series=True)
    def test003_enter_long_method_should_be_in_multiple_lines_in_order_form(
            self):
        """
        In case you select the method to display and you entered long text in it,
        the method should display into multiple lines in the order form

        LIMS-6663
        """
        self.orders_page.sleep_tiny()
        self.test_units_page.get_test_units_page()
        self.orders_page.sleep_tiny()
        self.test_units_page.open_configurations()
        self.orders_page.sleep_tiny()
        self.test_units_page.open_testunit_name_configurations_options()
        self.test_units_page.select_option_to_view_search_with(
            view_search_options=['Method'])
        self.info(' create test unit with long method text ')
        api, payload = self.test_unit_api.create_test_unit_with_long_text()
        self.assertEqual(api['status'], 1, payload)
        self.info('go to orders page')
        self.order_page.get_orders_page()
        self.info('create new order with the test unit of long method text')
        self.suborder_table.create_new_order(save=False,
                                             material_type='Raw Material')
        self.suborder_table.set_test_units(test_units=[payload['method']],
                                           remove_old=True)
        self.orders_page.save(save_btn='order:save_btn')
        self.info('assert method text appears in multiple lines')
        self.order_page.get_table_with_add()
        multiple_lines_properties = self.suborder_table.get_testunit_multiple_line_properties(
        )
        self.assertEquals(multiple_lines_properties['textOverflow'], 'clip')
        self.assertEquals(multiple_lines_properties['lineBreak'], 'auto')

    @parameterized.expand(['Name', 'Method', 'Unit', 'No'])
    @attr(series=True)
    def test004_search_with_test_unit_name_method(self, search_by):
        """
        Orders:Test unit search approach
        allow user to search with test unit name in the drop down list of the order form
        LIMS-6664
        allow user to search with test unit method in the drop down list of order form
        LIMS-6666
        allow user to search with test unit type in the drop down list of order form
        LIMS-6668
        allow user to search with test unit number in the drop down list of order form
        LIMS-6665

        """
        response, payload = self.test_unit_api.create_quantitative_testunit(
            unit="RandomUnit")
        self.assertEqual(response['status'], 1)
        self.test_units_page.get_test_units_page()
        self.orders_page.sleep_tiny()
        self.test_units_page.open_configurations()
        self.orders_page.sleep_tiny()
        self.test_units_page.open_testunit_name_configurations_options()
        self.test_units_page.select_option_to_view_search_with(
            view_search_options=[search_by])
        self.order_page.get_orders_page()

        if search_by == 'Name':
            testunit_search = payload['name']
        elif search_by == 'Method':
            testunit_search = payload['method']
        elif search_by == 'Unit':
            testunit_search = payload['unit']
        elif search_by == 'No':
            testunit_search = str(payload['number'])

        testunits = self.suborder_table.create_new_order_get_test_unit_suggetion_list(
            test_unit_name=testunit_search)

        self.info('checking {} field only is displayed'.format(search_by))
        self.assertGreater(len(testunits), 0)

    @parameterized.expand([('Name', 'Type'), ('Unit', 'No'),
                           ('Quantification Limit', '')])
    @attr(series=True)
    def test005_test_unit_name_allow_user_to_filter_with_selected_two_options_order(
            self, search_view_option1, search_view_option2):
        """
         Orders: Filter test unit Approach: Allow the search criteria in
         the drop down list in the filter section to be same as in the form

         LIMS-7411
        """
        self.test_units_page.get_test_units_page()
        self.test_units_page.open_configurations()
        self.test_units_page.open_testunit_name_configurations_options()
        self.test_units_page.select_option_to_view_search_with(
            view_search_options=[search_view_option1, search_view_option2])

        upperLimit = self.generate_random_number(lower=50, upper=100)
        lowerLimit = self.generate_random_number(lower=1, upper=49)
        self.info(
            'Create new quantitative test unit with unit and quantification')
        response, payload = self.test_unit_api.create_quantitative_testunit(
            useSpec=False,
            useQuantification=True,
            quantificationUpperLimit=upperLimit,
            quantificationLowerLimit=lowerLimit,
            unit='m[g]{o}')
        self.assertEqual(response['status'], 1, payload)
        formated_tu, _ = self.test_unit_api.get_testunit_form_data(
            response['testUnit']['testUnitId'])
        test_unit = [{
            'id': formated_tu['testUnit']['id'],
            'name': formated_tu['testUnit']['name']
        }]
        self.info('create new order created test unit number'.format(payload))
        res, order = self.orders_api.create_new_order(testUnits=test_unit)
        self.assertEqual(res['status'], 1,
                         'order not created with {}'.format(order))
        if search_view_option1 == 'Name' and search_view_option2 == 'Type':
            filter_text = payload['name']
        elif search_view_option1 == 'Unit' and search_view_option2 == 'No':
            filter_text = str(payload['number'])
        else:
            filter_text = str(payload['quantificationLowerLimit']) + '-' + str(
                payload['quantificationUpperLimit'])

        self.orders_page.get_orders_page()
        self.orders_page.sleep_tiny()
        self.orders_page.open_filter_menu()
        self.base_selenium.wait_element(element='orders:test_units_filter')
        self.orders_page.filter_by(filter_element='orders:test_units_filter',
                                   filter_text=filter_text)
        found_filter_text = self.base_selenium.get_text(
            'orders:test_units_filter').replace("\n×", "")
        if search_view_option1 == 'Name' and search_view_option2 == 'Type':
            self.assertEqual(found_filter_text,
                             payload['name'] + ': Quantitative')
        elif search_view_option1 == 'Unit' and search_view_option2 == 'No':
            self.assertEqual(found_filter_text,
                             'm[g]{o}: ' + str(payload['number']))
        else:
            self.assertEqual(found_filter_text, filter_text)

        self.orders_page.filter_apply()
        self.orders_page.sleep_tiny()
        results = self.order_page.result_table()
        self.assertGreaterEqual(len(results), 1)
        for i in range(len(results) - 1):
            suborders = self.orders_page.get_child_table_data(index=i)
            key_found = False
            for suborder in suborders:
                if payload['name'] == suborder['Test Units']:
                    key_found = True
                    break
            self.assertTrue(key_found)
            # close child table
            self.orders_page.close_child_table(source=results[i])

    @parameterized.expand(['Quantitative', 'Qualitative', 'Quantitative MiBi'])
    @attr(series=True)
    def test006_test_unit_with_sub_and_super_unit_name_appears_in_unit_field_drop_down(
            self, type):
        """
        New: Test unit: Export: In case the unit field with sub & super,
        allow this to display in the unit field drop down list in the analysis form

        LIMS-6675
        """
        self.test_unit_api.set_name_configuration_unit_only()
        if type == 'Quantitative':
            self.info('Create new Quantitative testunit')
            response, payload = self.test_unit_api.create_quantitative_testunit(
                unit='m[g]{o}')
        elif type == 'Qualitative':
            self.info('Create new Qualitative testunit')
            response, payload = self.test_unit_api.create_qualitative_testunit(
                unit='m[g]{o}')
        else:
            self.info('Create new Quantitative MiBi testunit')
            response, payload = self.test_unit_api.create_mibi_testunit(
                unit='m[g]{o}')

        self.assertEqual(response['status'], 1,
                         'test unit not created {}'.format(payload))
        self.info('go to orders page')
        self.order_page.get_orders_page()
        unit = self.suborder_table.create_new_order_get_test_unit_suggetion_list(
            material_type='', test_unit_name='m[g]{o}')
        self.assertIn("m[g]{o}", unit)

    @parameterized.expand(['sub_script', 'super_script'])
    @attr(series=True)
    def test007_filter_testunit_by_scripts(self, value):
        """
         Make sure that user can filter by sub & super scripts in the filter drop down list

         LIMS-7447
         LIMS-7444
        """
        self.test_unit_api.set_name_configuration_unit_only()
        if value == 'sub_script':
            api, testunit = self.test_unit_api.create_qualitative_testunit(
                unit='14[158]')
        else:
            api, testunit = self.test_unit_api.create_qualitative_testunit(
                unit='15{158}')
        self.assertEqual(api['status'], 1)
        unit = testunit['unit']
        self.orders_page.get_orders_page()
        self.order_page.sleep_small()
        self.base_selenium.scroll(False)
        self.orders_page.apply_filter_scenario(
            filter_element='orders:test_units_filter',
            filter_text=unit,
            field_type='drop_down')
        self.assertIsNotNone(
            self.base_selenium.is_text_included_in_drop_down_items(
                element='orders:test_units_filter', item_text=unit))

        results = self.order_page.result_table()
        self.assertGreaterEqual(len(results), 1)
        for i in range(len(results) - 1):
            suborders = self.orders_page.get_child_table_data(index=i)
            key_found = False
            for suborder in suborders:
                if unit in suborder['Test Units']:
                    key_found = True
                    break
            self.assertTrue(key_found)
            # close child table
            self.orders_page.open_child_table(source=results[i])

    @parameterized.expand(['Name', 'No', 'Name:No'])
    @attr(series=True)
    def test008_change_contact_config(self, search_by):
        """
         Orders: Contact configuration approach: In case the user
         configures the contact field to display name & number this action
         should reflect on the order active table
         LIMS-6632
        """
        self.contacts_page = Contacts()
        self.info('get random contact')
        contacts_response, _ = ContactsAPI().get_all_contacts(limit=10)
        self.assertEqual(contacts_response['status'], 1)
        payload = random.choice(contacts_response['contacts'])
        self.orders_page.open_order_config()
        self.info('change contact view by options')
        self.contacts_page.open_contact_configurations_options()
        if search_by == 'Name':
            search_text = payload['name']
            result = payload['name']
            search_by = [search_by]
        elif search_by == 'No':
            search_text = 'No: ' + str(payload['companyNo'])
            result = str(payload['companyNo'])
            search_by = [search_by]
        elif search_by == 'Name:No':
            search_text = payload['name'] + ' No: ' + str(payload['companyNo'])
            search_by = search_by.split(':')
            result = payload['name']

        self.contacts_page.select_option_to_view_search_with(
            view_search_options=search_by)
        self.info('go to order active table')
        self.orders_page.get_orders_page()
        self.orders_page.filter_by_contact(filter_text=result)
        rows = self.orders_page.result_table()
        order_data = self.base_selenium.get_row_cells_dict_related_to_header(
            row=rows[0])
        self.info('assert contact appear in format {}'.format(search_by))
        self.assertEqual(order_data['Contact Name'], search_text)

    @attr(series=True)
    def test009_update_contact_config_to_number_create_form(self):
        """
        Sample Management: Contact configuration approach: In case the user configures the
        contact field to display number this action should reflect on the order form step one

        LIMS-6626
        """
        self.info("set contact configuration to be searchable by number only")
        self.orders_api.set_contact_configuration_to_number_only()
        response, _ = ContactsAPI().get_all_contacts()
        self.assertEqual(response['status'], 1)
        self.assertGreaterEqual(response['count'], 1)
        random_contact = random.choice(response['contacts'])
        contact_no = random_contact['companyNo']
        contact_name = random_contact['name']
        testplan = TestPlanAPI().create_completed_testplan_random_data()
        self.info("create new order with contact no {}".format(contact_no))
        self.suborder_table.create_new_order(
            contacts=[contact_no],
            save=False,
            material_type=testplan['materialType'][0]['text'],
            article=testplan['selectedArticles'][0]['text'],
            test_plans=[testplan['testPlan']['text']])
        self.info("assert that contact set to {}".format(
            str('No: ' + contact_no)))
        self.assertCountEqual(self.order_page.get_contacts(),
                              [str('No: ' + contact_no)])
        self.order_page.clear_contact()
        contact_name_result = self.base_selenium.get_drop_down_suggestion_list(
            element='order:contact', item_text=contact_name)
        self.info(
            "assert that suggestion list of contact name {} is {}".format(
                contact_name, str('No: ' + contact_no)))

        self.assertEqual(contact_name_result[0], str('No: ' + contact_no))
class OrdersWithoutArticleTestCases(BaseTest):
    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()

    def tearDown(self):
        article_enabled = self.general_utilities.is_article_enabled()
        if not article_enabled:
            self.header_page.get_modules_config_page()
            self.header_page.disable_article_option()
        return super().tearDown()

    @attr(series=True)
    def test001_create_order_without_article(self):
        """
        orders without articles: check that user can create order without article

        LIMS-3253
        """
        created_testplan = TestPlanAPI().create_completed_testplan_random_data(
        )
        self.assertTrue(created_testplan)
        formatted_material = created_testplan['materialType'][0]
        created_testunit = self.test_unit_api.create_qualitative_testunit(
            selectedMaterialTypes=[formatted_material])
        self.info(
            'asserting article is not found in orders active table configuration'
        )
        child_table_header = self.orders_page.navigate_to_child_table_configuration(
        )
        self.assertNotIn('Article Name', child_table_header)
        self.orders_page.open_child_table(self.orders_page.result_table()[0])
        header_row = self.base_selenium.get_table_head_elements(
            element='general:table_child')
        displayed_headers = [h.text for h in header_row]
        self.info('asserting article is not displayed in orders table')
        self.assertNotIn('Article Name', displayed_headers)
        order_no, testunits, testplans = self.suborder_table.create_new_order(
            material_type=formatted_material['text'],
            test_plans=[created_testplan['testPlan']['text']],
            test_units=[created_testunit[1]['name']],
            article=None,
            check_testunits_testplans=True)

        self.info('asserting article field is not displayed in new order page')
        fields = self.base_selenium.get_table_head_elements(
            element='order:suborder_table')
        fields_text = [f.text for f in fields]
        self.assertNotIn('Article: *', fields_text)

        self.info(
            'asserting All displayed testunits are loaded correctly according to '
            'selected material type {}'.format(formatted_material['text']))
        testunit_materials = self.test_unit_api.get_testunits_material_types(
            testunits)
        self.assertTrue(
            all(material in ['All', formatted_material['text']]
                for material in testunit_materials))
        self.info(
            'asserting All displayed testplans are loaded correctly according to '
            'selected material type {}'.format(formatted_material['text']))
        testplan_materials = self.test_plan_api.get_testplans_matches_material_types(
            testplans=testplans, material_type=formatted_material['text'])
        self.assertTrue(
            all(material in [formatted_material['text']]
                for material in testplan_materials))
        self.order_page.sleep_tiny()
        self.order_page.get_orders_page()
        self.order_page.sleep_tiny()
        self.order_page.filter_by_order_no(filter_text=order_no)
        latest_order_data = \
            self.base_selenium.get_row_cells_dict_related_to_header(row=self.order_page.result_table()[0])
        self.info('asserting the order is successfully created')
        self.assertEqual(order_no.replace("'", ""),
                         latest_order_data['Order No.'].replace("'", ""))

    @attr(series=True)
    def test002_create__order_from_existing_order_without_article(self):
        """
         Orders without articles: when creating a new order from existing order,
         all data should be loaded, without article

         LIMS-3254
        """
        created_testplan = TestPlanAPI().create_completed_testplan_random_data(
        )
        self.assertTrue(created_testplan)
        formatted_material = created_testplan['materialType'][0]
        created_testunit = self.test_unit_api.create_qualitative_testunit(
            selectedMaterialTypes=[formatted_material])
        material_type = formatted_material['text']
        self.info('create order from an existing one')
        self.orders_page.sleep_tiny()
        order_no = self.order_page.create_existing_order_with_auto_fill()
        self.assertFalse(
            self.base_selenium.check_element_is_exist(element='order:article'))
        self.info('switch to material type {}'.format(material_type))
        self.suborder_table.set_material_type(material_type=material_type)
        self.assertEqual(
            self.base_selenium.get_value(element='order:test_unit'), None)
        self.assertEqual(
            self.base_selenium.get_value(element='order:test_plan'), None)
        testunits = self.base_selenium.get_drop_down_suggestion_list(
            element='order:test_unit', item_text=' ')
        _testplans = self.base_selenium.get_drop_down_suggestion_list(
            element='order:test_plan', item_text=' ')

        testplans = list(set(_testplans) - set(testunits))
        self.info(
            'asserting All displayed testunits are loaded correctly according to '
            'selected material type {}'.format(material_type))
        testunit_materials = self.test_unit_api.get_testunits_material_types(
            testunits)
        self.assertTrue(
            all(material in ['All', material_type]
                for material in testunit_materials))

        self.info(
            'asserting All displayed testplans are loaded correctly according to '
            'selected material type {}'.format(material_type))
        testplan_materials = self.test_plan_api.get_testplans_matches_material_types(
            testplans=testplans, material_type=material_type)
        self.assertTrue(
            all(material in [material_type]
                for material in testplan_materials))

        self.suborder_table.set_test_units(
            test_units=[created_testunit[1]['name']])
        self.suborder_table.set_test_plans(
            test_plans=[created_testplan['testPlan']['text']])
        self.order_page.save(save_btn='order:save_btn')
        self.info('assert order is created successfully')
        self.orders_page.get_orders_page()
        self.orders_page.filter_by_order_no(filter_text=order_no)
        results = self.order_page.result_table()[0].text
        self.assertIn(order_no.replace("'", ""), results.replace("'", ""))
コード例 #9
0
class ArticlesTestCases(BaseTest):
    def setUp(self):
        super().setUp()
        self.login_page = Login()
        self.article_page = Article()
        self.test_plan = TstPlan()
        self.order = Order()
        self.login_page.login(username=self.base_selenium.username,
                              password=self.base_selenium.password)
        self.base_selenium.wait_until_page_url_has(text='dashboard')
        self.article_page.get_article_page()

    @parameterized.expand(['save', 'cancel'])
    def test001_cancel_button_edit_unit(self, save):
        """
        New: Article: Save/Cancel button: After I edit unit field then press on cancel button,
        a pop up will appear that the data will be

        LIMS-3586
        LIMS-3576
        :return:
        """
        self.article_page.get_random_article()
        article_url = self.base_selenium.get_url()
        self.base_selenium.LOGGER.info(
            ' + article_url : {}'.format(article_url))
        current_unit = self.article_page.get_unit()
        new_unit = self.generate_random_string()
        self.article_page.set_unit(new_unit)
        if 'save' == save:
            self.article_page.save()
        else:
            self.article_page.cancel(force=True)

        self.base_selenium.get(url=article_url,
                               sleep=self.base_selenium.TIME_MEDIUM)

        article_unit = self.article_page.get_unit()
        if 'save' == save:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (new_unit) == {} (article_unit)'.format(
                    new_unit, article_unit))
            self.assertEqual(new_unit, article_unit)
        else:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (current_unit) == {} (article_unit)'.format(
                    current_unit, article_unit))
            self.assertEqual(current_unit, article_unit)

    @parameterized.expand(['save', 'cancel'])
    def test002_cancel_button_edit_no(self, save):
        """
        New: Article: Save/Cancel button: After I edit no field then press on cancel button,
        a pop up will appear that the data will be

        LIMS-3586
        LIMS-3576
        :return:
        """
        self.article_page.get_random_article()
        article_url = self.base_selenium.get_url()
        self.base_selenium.LOGGER.info(
            ' + article_url : {}'.format(article_url))
        current_no = self.article_page.get_no()
        new_no = self.generate_random_string()
        self.article_page.set_no(new_no)
        if 'save' == save:
            self.article_page.save()
        else:
            self.article_page.cancel(force=True)

        self.base_selenium.get(url=article_url,
                               sleep=self.base_selenium.TIME_MEDIUM)

        article_no = self.article_page.get_no()
        if 'save' == save:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (new_no) == {} (article_no)'.format(
                    new_no, article_no))
            self.assertEqual(new_no, article_no)
        else:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (current_no) == {} (article_no)'.format(
                    current_no, article_no))
            self.assertEqual(current_no, article_no)

    @parameterized.expand(['save', 'cancel'])
    def test003_cancel_button_edit_name(self, save):
        """
        New: Article: Save/Cancel button: After I edit name then press on cancel button,
        a pop up will appear that the data will be

        LIMS-3586
        LIMS-3576
        :return:
        """
        self.article_page.get_random_article()
        article_url = self.base_selenium.get_url()
        self.base_selenium.LOGGER.info(
            ' + article_url : {}'.format(article_url))
        current_name = self.article_page.get_name()
        new_name = self.generate_random_string()
        self.article_page.set_name(new_name)

        if 'save' == save:
            self.article_page.save()
        else:
            self.article_page.cancel(force=True)

        self.base_selenium.get(url=article_url,
                               sleep=self.base_selenium.TIME_MEDIUM)

        article_name = self.article_page.get_name()
        if 'save' == save:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (new_name) == {} (article_name)'.format(
                    new_name, article_name))
            self.assertEqual(new_name, article_name)
        else:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (current_name) == {} (article_name)'.format(
                    current_name, article_name))
            self.assertEqual(current_name, article_name)

    @parameterized.expand(['save', 'cancel'])
    def test004_cancel_button_edit_comment(self, save):
        """
        New: Article: Save/Cancel button: After I edit comment then press on cancel button,
        a pop up will appear that the data will be

        LIMS-3586
        LIMS-3576
        :return:
        """
        self.article_page.get_random_article()
        article_url = self.base_selenium.get_url()
        self.base_selenium.LOGGER.info(
            ' + article_url : {}'.format(article_url))
        current_comment = self.article_page.get_comment()
        new_comment = self.generate_random_string()
        self.article_page.set_comment(new_comment)
        if 'save' == save:
            self.article_page.save()
        else:
            self.article_page.cancel(force=True)

        self.base_selenium.get(url=article_url,
                               sleep=self.base_selenium.TIME_MEDIUM)

        article_comment = self.article_page.get_comment()
        if 'save' == save:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (new_comment) == {} (article_comment)'.format(
                    new_comment, article_comment))
            self.assertEqual(new_comment, article_comment)
        else:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (current_comment) == {} (article_comment)'.
                format(current_comment, article_comment))
            self.assertEqual(current_comment, article_comment)

    @parameterized.expand(['save', 'cancel'])
    def test005_cancel_button_edit_material_type(self, save):
        """
        New: Article: Save/Cancel button: After I edit material_type then press on cancel button,
        a pop up will appear that the data will be

        LIMS-3586
        LIMS-3576
        :return:
        """
        self.article_page.get_random_article()
        article_url = self.base_selenium.get_url()
        self.base_selenium.LOGGER.info(
            ' + article_url : {}'.format(article_url))
        current_material_type = self.article_page.get_material_type()
        self.article_page.set_material_type(random=True)
        new_material_type = self.article_page.get_material_type()
        if 'save' == save:
            self.article_page.save()
        else:
            self.article_page.cancel(force=True)

        self.base_selenium.get(url=article_url, sleep=5)

        article_material = self.article_page.get_material_type()
        if 'save' == save:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (new_material_type) == {} (article_material_type)'
                .format(new_material_type, article_material))
            self.assertEqual(new_material_type,
                             self.article_page.get_material_type())
        else:
            self.base_selenium.LOGGER.info(
                ' + Assert {} (current_material_type) == {} (article_material_type)'
                .format(current_material_type, article_material))
            self.assertEqual(current_material_type,
                             self.article_page.get_material_type())

    def test006_archived_articles_shoudnt_dispaly_in_test_plan(self):
        """
        New: Article: In case I archived any article this article shouldn't display in the test plan module when
         I create test plan or edit it

         LIMS-3668
        :return:
        """
        self.article_page.create_new_article(material_type='Raw Material')
        self.base_selenium.LOGGER.info(' + Archive the article.')
        self.article_page.archive_article(name=self.article_page.article_name)
        self.test_plan.get_test_plans_page()
        self.base_selenium.LOGGER.info(
            ' + Create test plan with the same material type.')
        self.test_plan.click_create_test_plan_button()
        self.test_plan.set_material_type(
            material_type=self.article_page.article_material_type)
        self.article_page.sleep_tiny()
        self.base_selenium.LOGGER.info(
            ' + Assert article is not existing in the list.')
        self.assertFalse(
            self.test_plan.is_article_existing(
                article=self.article_page.article_name))

    def test007_archived_articles_shoudnt_dispaly_in_order(self):
        """
        New: Article: Archived any article this article shouldn't display in the order module

         LIMS-3668
        :return:
        """
        self.article_page.create_new_article(material_type='Raw Material')
        self.article_page.archive_article(name=self.article_page.article_name)
        self.order.get_orders_page()
        self.order.click_create_order_button()
        self.order.set_new_order()
        self.order.set_material_type(
            material_type=self.article_page.article_material_type)
        self.article_page.sleep_tiny()
        self.assertFalse(
            self.order.is_article_existing(
                article=self.article_page.article_name))

    def test008_created_article_appear_in_test_plan(self):
        """
            New: Article/Test plan: Any article I created should appear in the test plan according to the materiel type.

            LIMS-3581
        :return:
        """
        self.article_page.create_new_article(material_type='Raw Material')
        self.test_plan.get_test_plans_page()
        self.test_plan.click_create_test_plan_button()
        self.test_plan.set_material_type(
            material_type=self.article_page.article_material_type)
        self.article_page.sleep_tiny()
        self.assertTrue(
            self.test_plan.is_article_existing(
                article=self.article_page.article_name))

    def test009_create_article_with_test_plan_search_by_test_plan(self):
        """
        In case I create test plan with the article that I created, this test plan should display in the table view

        LIMS-3583
        :return:
        """
        self.article_page.create_new_article(material_type='Raw Material')
        self.test_plan.get_test_plans_page()
        self.test_plan.create_new_test_plan(
            material_type=self.article_page.article_material_type,
            article=self.article_page.article_name)
        self.article_page.get_article_page()
        self.article_page.sleep_small()
        article = self.article_page.search(
            value=self.test_plan.test_plan_name)[0]
        self.assertIn(self.test_plan.test_plan_name, article.text)

        self.test_plan.get_test_plans_page()
        self.test_plan.get_test_plan_edit_page(
            name=self.test_plan.test_plan_name)

        self.test_plan.clear_article()
        self.test_plan.set_article(article='All')
        self.test_plan.save()
        self.article_page.get_article_page()
        article = self.article_page.search(self.article_page.article_name)[0]
        self.assertNotIn(self.test_plan.test_plan_name, article.text)

    def test010_create_article_with_test_plan_filter_by_test_plan(self):
        """
        In case I create test plan with the article that I created, user could filter with test plan

        LIMS-3583
        :return:
        """
        self.article_page.create_new_article(material_type='Raw Material')
        self.test_plan.get_test_plans_page()
        self.test_plan.create_new_test_plan(
            material_type=self.article_page.article_material_type,
            article=self.article_page.article_name)
        self.article_page.get_article_page()
        self.article_page.sleep_small()

        self.article_page.filter_by_test_plan(
            filter_text=self.test_plan.test_plan_name)
        article = self.article_page.filter_result()[0]
        self.base_selenium.LOGGER.info(
            ' + Assert user could filter with test plan.')
        self.assertIn(self.test_plan.test_plan_name, article.text)

    def test011_archive_articles(self):
        """
        New: Article: Archive Approach: I can archive/restore any article successfully

        LIMS-3587
        :return:
        """
        selected_articles_data, _ = self.article_page.select_random_multiple_table_rows(
        )
        self.article_page.archive_selected_articles()
        self.article_page.get_archived_articles()
        for article in selected_articles_data:
            article_name = article['Article Name']
            self.base_selenium.LOGGER.info(
                ' + {} article should be activated.'.format(article_name))
            self.assertTrue(
                self.article_page.is_article_archived(value=article_name))

    def test012_restore_articles(self):
        """
        New: Article: Restore Approach: I can archive/restore any article successfully

        LIMS-3587
        :return:
        """
        article_names = []
        self.article_page.get_archived_articles()
        selected_articles_data, _ = self.article_page.select_random_multiple_table_rows(
        )
        for article in selected_articles_data:
            article_names.append(article['Article Name'])

        self.article_page.restore_selected_articles()
        self.article_page.get_active_articles()
        for article_name in article_names:
            self.assertTrue(
                self.article_page.is_article_archived(value=article_name))

    def test013_create_new_material_type(self):
        """
        Article: Materiel type Approach: make sure you can create new materiel type & this materiel type displayed correct according to this article.

        LIMS-3582
        :return:
        """
        material_type = self.generate_random_string()
        self.article_page.create_new_article(material_type=material_type)
        self.test_plan.get_test_plans_page()
        self.test_plan.click_create_test_plan_button()
        self.test_plan.set_material_type(
            material_type=self.article_page.article_material_type)
        self.article_page.sleep_tiny()
        self.assertTrue(
            self.test_plan.is_article_existing(
                article=self.article_page.article_name))

    def test014_article_search(self):
        """
        New: Articles: Search Approach: I can search by any field in the table view

        LIMS-3594
        :return:
        """
        row = self.article_page.get_random_article_row()
        row_data = self.base_selenium.get_row_cells_dict_related_to_header(
            row=row)
        for column in row_data:
            if re.findall(r'\d{1,}.\d{1,}.\d{4}',
                          row_data[column]) or row_data[column] == '':
                continue
            self.base_selenium.LOGGER.info(' + search for {} : {}'.format(
                column, row_data[column]))
            search_results = self.article_page.search(row_data[column])
            self.assertGreater(
                len(search_results), 1,
                " * There is no search results for it, Report a bug.")
            for search_result in search_results:
                search_data = self.base_selenium.get_row_cells_dict_related_to_header(
                    search_result)
                if search_data[column] == row_data[column]:
                    break
            self.assertEqual(row_data[column], search_data[column])

    def test015_green_border(self):
        """
        New: All modules: Creation Approach: Green border displayed when I create new record

        LIMS-3597
        :return:
        """
        self.article_page.create_new_article(sleep=False,
                                             material_type='Raw Material')
        self.assertEqual(
            self.base_selenium.get_text(element='articles:alert_confirmation'),
            'Successfully created')

    def test016_create_full_options_article(self):
        """
        New: Articles: Creation Approach: I can create new article successfully

        LIMS-3575
        :return:
        """
        self.article_page.create_new_article(full_options=True,
                                             material_type='Raw Material')
        article_text = self.article_page.search(
            value=self.article_page.article_name)[0].text
        self.assertIn(self.article_page.article_unit, article_text)
        self.assertIn(self.article_page.article_comment, article_text)
        self.assertIn(self.article_page.article_material_type, article_text)

    def test017_delete_article_with_test_plan(self):
        """
        New: Articles: Delete Approach; I can't delete any article if this article related to some data

        LIMS-3577
        :return:
        """
        self.article_page.create_new_article(material_type='Raw Material')
        self.test_plan.get_test_plans_page()
        self.test_plan.create_new_test_plan(
            material_type=self.article_page.article_material_type,
            article=self.article_page.article_name)
        self.article_page.get_article_page()
        self.article_page.sleep_small()
        article = self.article_page.search(
            value=self.test_plan.test_plan_name)[0]

        self.article_page.click_check_box(source=article)
        self.article_page.archive_selected_articles()

        self.article_page.get_archived_articles()
        archived_article = self.article_page.search(
            value=self.test_plan.test_plan_name)[0]
        self.article_page.click_check_box(source=archived_article)
        self.assertFalse(self.article_page.delete_selected_article())

    def test018_delete_article_with_order(self):
        """
        New: Articles: Delete Approach; I can't delete any article if this article related to some data

        LIMS-3577
        :return:
        """
        self.base_selenium.LOGGER.info(
            ' + Create new article with Raw Material.')
        self.article_page.create_new_article(material_type='Raw Material')
        self.test_plan.get_test_plans_page()
        self.base_selenium.LOGGER.info(
            ' + Create new test plan with {} article.'.format(
                self.article_page.article_name))
        self.test_plan.create_new_test_plan(
            material_type=self.article_page.article_material_type,
            article=self.article_page.article_name,
            test_unit='Qualitative')
        self.order.get_orders_page()
        self.order.click_create_order_button()
        self.base_selenium.LOGGER.info(
            ' + Create new order with {} article.'.format(
                self.article_page.article_name))
        self.order.create_new_order(
            article=self.article_page.article_name,
            material_type=self.article_page.article_material_type,
            test_plan=self.test_plan.test_plan_name)

        self.article_page.get_article_page()
        self.article_page.sleep_small()
        self.base_selenium.LOGGER.info(
            ' + Search for active article with {} test plan.'.format(
                self.test_plan.test_plan_name))
        search_results = self.article_page.search(
            value=self.test_plan.test_plan_name)
        self.assertGreater(
            len(search_results), 1,
            " * There is no search results for it, Report a bug.")
        for search_result in search_results:
            search_data = self.base_selenium.get_row_cells_dict_related_to_header(
                search_result)
            if self.test_plan.test_plan_name in search_data['Test Plans']:
                break
            self.base_selenium.LOGGER.debug(' Article test plan : {} '.format(
                search_data['Test Plans']))
        else:
            raise ValueError(
                " There is no active article with {} test plan".format(
                    self.test_plan.test_plan_name))
        self.base_selenium.LOGGER.info(' + Archive this article.')
        self.article_page.click_check_box(source=search_result)
        self.article_page.archive_selected_articles()

        self.article_page.get_archived_articles()
        self.base_selenium.LOGGER.info(
            ' + Search for archived article with {} test plan.'.format(
                self.test_plan.test_plan_name))
        search_results = self.article_page.search(
            value=self.test_plan.test_plan_name)
        self.assertGreater(
            len(search_results), 1,
            " * There is no search results for it, Report a bug.")
        for search_result in search_results:
            search_data = self.base_selenium.get_row_cells_dict_related_to_header(
                search_result)
            if self.test_plan.test_plan_name in search_data['Test Plans']:
                break
            self.base_selenium.LOGGER.debug(' Article test plan : {} '.format(
                search_data['Test Plans']))
        else:
            raise ValueError(
                " There is no archived article with {} test plan".format(
                    self.test_plan.test_plan_name))

        self.base_selenium.LOGGER.info(' + Delete this article, should fail.')
        self.article_page.click_check_box(source=search_result)
        self.assertFalse(self.article_page.delete_selected_article())

    def test019_download_article_sheet(self):
        """
        New: Articles: XSLX File: I can download all the data in the table view in the excel sheet

        LIMS:3589
        :return:
        """
        self.base_selenium.LOGGER.info(' * Download XSLX sheet')
        self.article_page.download_xslx_sheet()
        rows_data = self.article_page.get_articles_rows_data()
        for index in range(len(rows_data)):
            self.base_selenium.LOGGER.info(
                ' * Comparing the article no. {} '.format(index))
            fixed_row_data = self.fix_data_format(rows_data[index].split('\n'))
            values = self.article_page.article_sheet.iloc[index].values
            fixed_sheet_row_data = self.fix_data_format(values)
            for item in fixed_row_data:
                self.assertIn(item, fixed_sheet_row_data)
コード例 #10
0
class TestPlansTestCases(BaseTest):
    def setUp(self):
        super().setUp()
        self.test_plan = TstPlan()
        self.test_plan_api = TestPlanAPI()
        self.article_api = ArticleAPI()
        self.test_plan.get_test_plans_page()
        self.test_plan_api.set_configuration()

    def test001_test_plan_delete_testunit(self):
        """
        Testing deleting a test unit from test-plan create or update step two
        It deletes the first test unit in the chosen test plan and saves this,
        then refreshes the page and checks if the deletion was done correctly.

        LIMS-3504
        """
        self.info("get random completed test plan")
        random_completed_test_plan = random.choice(
            self.test_plan_api.get_completed_testplans())
        self.info("navigate to the test-plan No. {} edit page".format(
            random_completed_test_plan['number']))
        self.test_plan.get_test_plan_edit_page_by_id(
            random_completed_test_plan['id'])
        old_testunits = self.test_plan.get_all_testunits_in_testplan()
        self.assertTrue(old_testunits,
                        "There's no test units in this test plan")
        deleted_test_unit = (old_testunits[0])[0]
        self.info("delete the first test unit with name {}".format(
            deleted_test_unit))
        self.test_plan.delete_the_first_testunit_from_the_tableview()
        self.info(
            "save the changes and refresh to make sure test unit deleted")
        self.test_plan.save_and_confirm_popup()
        all_testunits = self.test_plan.get_all_testunits_in_testplan()
        self.info('Checking if the changes were saved successfully')
        deleted_test_unit_found = self.test_plan.check_if_deleted_testunit_is_available(
            all_testunits=all_testunits, deleted_test_unit=deleted_test_unit)
        self.assertFalse(deleted_test_unit_found)

    @parameterized.expand(['InProgress', 'Completed'])
    def test002_test_plan_edit_status(self, status):
        """
        Creation Approach: when the status converted from completed to completed, new version created
        when the status converted from In-Progress to completed, no new version created

        LIMS-3502
        LIMS-3501
        """
        self.info(
            "create test unit of  material type  = All  to complete test plan")
        response, test_unit = TestUnitAPI().create_qualitative_testunit()
        self.assertEqual(response['status'], 1, 'can not create test unit')
        testplan = random.choice(
            self.test_plan_api.get_testplans_with_status(status=status))
        self.assertTrue(testplan, 'No test plan selected')
        self.info(
            'Navigate to edit page of test plan: {} with version: {}'.format(
                testplan['testPlanName'], testplan['version']))
        self.test_plan.get_test_plan_edit_page_by_id(testplan['id'])
        self.info('Going to step 2 to add test unit to this test plan')
        self.test_plan.sleep_tiny()
        self.test_plan.set_test_unit(test_unit=test_unit['name'])
        if status == 'InProgress':
            self.info('Saving and completing the test plan')
            self.test_plan.save(save_btn='test_plan:save_and_complete',
                                sleep=True)
        else:
            self.info('Saving and confirm pop up')
            self.test_plan.save_and_confirm_popup()

        self.info(
            "go back to the active table and get test plan to check its version and status"
        )
        self.test_plan.get_test_plans_page()
        new_test_plan_version, test_plan_row_data_status = \
            self.test_plan.get_testplan_version_and_status(search_text=testplan['testPlanName'])

        if status == 'InProgress':
            self.assertEqual(int(new_test_plan_version), testplan['version'])
        else:
            self.assertGreater(int(new_test_plan_version),
                               int(testplan['version']))

        self.assertEqual(test_plan_row_data_status, 'Completed')

    def test003_archive_test_plan_one_record(self):
        """
        Archive one record

        LIMS-3506 Case 1
        """
        self.info('choosing a random test plan table row')
        selected_test_plan = self.test_plan.select_random_table_row()
        self.assertTrue(selected_test_plan)
        self.info(f'selected_test_plan : {selected_test_plan}')
        testplan_number = selected_test_plan['Test Plan No.']
        self.info(
            'Archive the selected item and navigating to the archived items table'
        )
        self.test_plan.archive_selected_items()
        self.test_plan.get_archived_items()
        archived_row = self.test_plan.search(testplan_number)
        self.info(
            'Checking if test plan number: {} is archived correctly'.format(
                testplan_number))
        self.assertIn(selected_test_plan['Test Plan Name'],
                      archived_row[0].text)
        self.info('Test plan number: {} is archived correctly'.format(
            testplan_number))

    def test004_restore_test_plan_one_record(self):
        """
         Restore one record

         LIMS-3506 Case 1
        """
        self.info("Navigate to archived test plan table")
        self.test_plan.get_archived_items()
        self.info('Choosing a random testplan table row')
        self.test_plan.sleep_tiny()
        selected_test_plan = self.test_plan.select_random_table_row()
        self.info(f"selected_test_plan : {selected_test_plan}")
        self.assertTrue(selected_test_plan)
        testplan_number = selected_test_plan['Test Plan No.']
        self.info('select Testplan number: {} to be restored'.format(
            testplan_number))
        self.info(
            'Restoring the selected item then navigating to the active items table'
        )
        self.test_plan.restore_selected_items()
        self.test_plan.get_active_items()
        self.test_plan.filter_by_testplan_number(filter_text=testplan_number)
        restored_row = self.test_plan.result_table()
        self.info(
            'Checking if testplan number: {} is restored correctly'.format(
                testplan_number))
        self.assertIn(selected_test_plan['Test Plan Name'],
                      restored_row[0].text)
        self.info('Testplan number: {} is restored correctly'.format(
            testplan_number))

    def test005_archive_test_plan_multiple_records(self):
        """
        Archive multiple records

        LIMS-3506 Case 2
        """
        self.info('Choosing random multiple test plans table rows')
        self.test_plan.sleep_small()
        rows_data, rows = self.test_plan.select_random_multiple_table_rows()
        self.assertTrue(rows_data)
        testplans_numbers = [row['Test Plan No.'] for row in rows_data]
        self.info(
            'Testplan numbers: {} will be archived'.format(testplans_numbers))
        self.info(
            'Archiving the selected items and navigating to the archived items table'
        )
        self.test_plan.archive_selected_items()
        self.test_plan.sleep_small()
        self.info('Checking if testplans are archived correctly')
        self.test_plan.get_archived_items()
        archived_rows = self.test_plan.filter_multiple_rows_by_testplans_numbers(
            testplans_numbers)
        self.assertIsNotNone(archived_rows)
        self.assertEqual(len(archived_rows), len(testplans_numbers))
        self.info('Testplan numbers: {} are archived correctly'.format(
            testplans_numbers))

    def test006_restore_test_plan_multiple_records(self):
        """
        Rstore multiple records

        LIMS-3506 Case 2
        """
        self.info("Navigate to archived test plan table")
        self.test_plan.sleep_tiny()
        self.test_plan.get_archived_items()
        self.info('Choosing random multiple test plans table rows')
        self.test_plan.sleep_tiny()
        rows_data, rows = self.test_plan.select_random_multiple_table_rows()
        self.assertTrue(rows_data)
        testplans_numbers = [row['Test Plan No.'] for row in rows_data]
        self.info(
            'Restore Test plans with numbers: {}'.format(testplans_numbers))
        self.test_plan.restore_selected_items()
        self.test_plan.sleep_small()
        self.info('Navigate to active table and make sure test plans restored')
        self.test_plan.get_active_items()
        restored_rows = self.test_plan.filter_multiple_rows_by_testplans_numbers(
            testplans_numbers)
        self.assertIsNotNone(restored_rows)
        self.assertEqual(len(restored_rows), len(testplans_numbers))
        self.info('Test plans numbers: {} are restored correctly'.format(
            testplans_numbers))

    @skip('https://modeso.atlassian.net/browse/LIMS-6403')
    def test007_exporting_test_plan_one_record(self):
        """
        Exporting one record

        LIMS-3508 Case 1
        """
        self.info('choosing a random testplan table row')
        row = self.test_plan.get_random_table_row('general:table')
        row_data = self.base_selenium.get_row_cells_dict_related_to_header(
            row=row)
        testplan_number = row_data['Test Plan No.']
        self.info(
            'testplan number: {} will be exported'.format(testplan_number))
        self.info('Selecting the test plan row')
        self.test_plan.click_check_box(source=row)
        self.info('download XSLX sheet of selected test plan')
        self.test_plan.download_xslx_sheet()
        row_data_list = list(row_data.values())
        self.info('comparing the testplan no. {} '.format(testplan_number))
        values = self.test_plan.sheet.iloc[0].values
        fixed_sheet_row_data = self.fix_data_format(values)
        fixed_row_data_list = self.fix_data_format(row_data_list)
        for item in fixed_row_data_list:
            self.assertIn(item, fixed_sheet_row_data)

    @skip('https://modeso.atlassian.net/browse/LIMS-6403')
    def test008_exporting_test_plan_multiple_records(self):
        """
        Exporting multiple records

        LIMS-3508 Case 2
        """
        self.info('choosing random multiple testplans table rows')
        row_data_list = self.test_plan.select_random_multiple_table_rows(
            element='general:table')[0]
        self.test_plan.download_xslx_sheet()

        row_data = []
        sheet_data = []
        for index in range(len(row_data_list)):
            row_data.append(self.fix_data_format(
                row_data_list[index].values()))
            sheet_data.append(
                self.fix_data_format(self.test_plan.sheet.iloc[index].values))

        row_data = sorted(row_data)
        sheet_data = sorted(sheet_data)
        for index in range(len(row_data)):
            for item in row_data[index]:
                self.assertIn(item, sheet_data[index])

    def test009_test_plan_duplicate(self):
        """
        Duplicate a test plan

        LIMS-3679
        """
        self.info('Choosing a random testplan table row')
        testPlan = random.choice(self.test_plan_api.get_completed_testplans())
        self.assertTrue(testPlan, "No completed test plan selected")
        testunits = self.test_plan_api.get_testunits_in_testplan(
            id=testPlan['id'])
        self.assertTrue(
            testunits,
            "Completed test plan with id {} has no testunits!!".format(
                testPlan['id']))
        self.info("select test plan {}".format(testPlan['testPlanName']))
        self.test_plan.filter_by_testplan_number(testPlan['number'])
        row = self.test_plan.result_table()[0]
        self.test_plan.click_check_box(source=row)
        self.info('Duplicating testplan number: {}'.format(testPlan['number']))
        self.test_plan.duplicate_selected_item()
        duplicated_test_plan_number = self.test_plan.duplicate_testplan(
            change=['name'])
        self.info('testplan duplicated with number: {}'.format(
            duplicated_test_plan_number))
        self.info('get duplicated test plan data and child table data')
        duplicated_testplan_data, duplicated_testplan_childtable_data = \
            self.test_plan.get_specific_testplan_data_and_childtable_data(
                filter_by='number', filter_text=duplicated_test_plan_number)
        duplicated_test_units = []
        for testunit in duplicated_testplan_childtable_data:
            duplicated_test_units.append(testunit['Test Unit Name'])

        self.info('Asserting that the data is duplicated correctly')
        self.assertEqual(testPlan['materialTypes'][0],
                         duplicated_testplan_data['Material Type'])
        self.assertEqual(testPlan['article'][0],
                         duplicated_testplan_data['Article Name'])
        self.assertEqual(testPlan['articleNo'][0],
                         duplicated_testplan_data['Article No.'])
        for testunit in testunits:
            self.assertIn(testunit['name'], duplicated_test_units)

    def test010_test_plan_completed_to_inprogress(self):
        """
        When the test plan status is converted from completed to in progress a new version is created

        LIMS-3503
        """
        self.info('get random completed test plan')
        completed_testplan = random.choice(
            self.test_plan_api.get_completed_testplans())
        self.assertTrue(completed_testplan, "There's no completed test plans!")
        self.info(
            'Navigating to edit page of testplan: {} with version: {}'.format(
                completed_testplan['testPlanName'],
                completed_testplan['version']))
        self.test_plan.get_test_plan_edit_page_by_id(completed_testplan['id'])
        self.info('Going to step 2 to remove all the test units from it')
        self.test_plan.navigate_to_testunits_selection_page()
        self.test_plan.sleep_tiny()
        self.test_plan.delete_all_testunits()
        self.test_plan.save_and_confirm_popup()

        self.info("go back to active table")
        self.test_plan.get_test_plans_page()

        self.info(
            'Getting the currently changed testplan to check its status and version'
        )
        inprogress_testplan_version, testplan_row_data_status = \
            self.test_plan.get_testplan_version_and_status(search_text=completed_testplan['testPlanName'])

        self.assertEqual(completed_testplan['version'] + 1,
                         int(inprogress_testplan_version))
        self.assertEqual(testplan_row_data_status, 'In Progress')

    @parameterized.expand(['same', 'All'])
    def test011_create_testplans_same_name_article_materialtype(self, same):
        """
        Testing the creation of two testplans with the same name, material type
        and article, this shouldn't happen

        LIMS-3499

        New: Test plan: Creation Approach: I can't create two test plans
        with the same name & same materiel type & one with any article
        and the other one all

        LIMS-3500
        """
        payload = self.test_plan_api.create_completed_testplan_random_data()
        self.test_plan.click_create_test_plan_button()
        self.test_plan.set_test_plan(name=payload['testPlan']['text'])
        self.assertFalse(
            self.test_plan.is_material_type_existing(
                material_type=payload['materialType'][0]['text']))

    def test012_create_testplans_same_name_different_materialtype(self):
        """
        Testing the creation of two testplans with the same name, but different material type
        and article. It should be created successfully.

        LIMS-3498
        """
        self.info('create complete test plan')
        payload = self.test_plan_api.create_completed_testplan_random_data()
        self.assertTrue(payload, 'can not create a tesplan')
        articles = self.article_api.get_all_articles_json()
        for article in articles:
            if article['name'] != payload['selectedArticles'][0]['text'] and article['materialType'] != \
                    payload['materialType'][0]['text']:
                self.info(
                    'create another testplan with the same name, but with different material type and article name'
                )
                second_testplan_name = self.test_plan.create_new_test_plan(
                    name=payload['testPlan']['text'],
                    material_type=article['materialType'],
                    article=article['name'])
                self.info(
                    'new testplan is created successfully with name: {}, article name: {} and material type: {}'
                    .format(second_testplan_name, self.test_plan.article,
                            self.test_plan.material_type))

                self.assertEqual(payload['testPlan']['text'],
                                 second_testplan_name)
                data = self.test_plan.search(second_testplan_name)
                self.assertGreaterEqual(len(data), 2)
                break

    def test013_delete_used_testplan(self):
        """
        If a test plan is used, it can't be deleted

        LIMS-3509
        """
        self.info("create order with test plan")
        response, payolad = OrdersAPI().create_new_order()
        self.assertEqual(response['status'], 1, payolad)
        self.info("created order no {} has testplan name {}".format(
            payolad[0]['orderNo'], payolad[0]['testPlans'][0]['name']))
        self.info('testplan name: {} will be archived'.format(
            payolad[0]['testPlans'][0]['name']))
        self.test_plan.base_selenium.refresh()
        testplan_deleted = self.test_plan.delete_selected_item_from_active_table_and_from_archived_table(
            item_name=payolad[0]['testPlans'][0]['name'])

        self.info(
            "check for the error popup that this testplan is used and can't be deleted"
        )
        self.assertFalse(testplan_deleted)

    def test014_archived_testplan_shouldnot_appear_in_order(self):
        """
        In case a testplan is archived, it shouldn't appear when creating a new order

        LIMS-3708
        """
        self.info("navigate to orders page")
        self.order_page = Order()
        self.info("get random archived testplan")
        response, payload = self.test_plan_api.get_all_test_plans()
        self.assertEqual(response['status'], 1, payload)
        archived_test_plan = random.choice(response['testPlans'])
        self.test_plan_api.archive_testplans(
            ids=[str(archived_test_plan['id'])])
        self.order_page.get_orders_page()

        self.info("archived test plan data {}".format(archived_test_plan))
        self.info(
            "create a new order with material type and article of archived testplan"
        )
        if archived_test_plan['article'] != ['all']:
            self.order_page.create_new_order(
                material_type=archived_test_plan['materialTypes'][0],
                article=archived_test_plan['article'][0],
                test_plans=[archived_test_plan['testPlanName']])
        else:
            self.order_page.create_new_order(
                material_type=archived_test_plan['materialTypes'][0],
                test_plans=[archived_test_plan['testPlanName']])
        order_data = self.order_page.get_suborder_data()
        self.info(
            "get the first suborder's testplan and make sure it's an empty string"
        )
        self.assertCountEqual(order_data['suborders'][0]['testplans'], [''])

    def test015_testunit_sub_super_scripts(self):
        """
        Create a testunit with sub/super scripts, use this testunit to create a testplan
        and check the sub/super scripts in the card view

        LIMS-5796
        """
        self.info("create test unit with sub and super scripts")
        response, payload = TestUnitAPI().create_qualitative_testunit(
            unit='mg[2]{o}')
        self.assertEqual(response['status'], 1, payload)
        self.info("created test unit data {}".format(payload))
        self.info("create test plan with same created test unit data")
        if payload['selectedMaterialTypes'][0]['text'] == 'All':
            self.test_plan.create_new_test_plan(test_unit=payload['name'],
                                                save=False)
        else:
            self.test_plan.create_new_test_plan(
                material_type=payload['selectedMaterialTypes'][0]['text'],
                test_unit=payload['name'],
                save=False)

        unit = self.base_selenium.find_element('test_plan:testunit_unit').text
        self.assertEqual(unit, 'mg2o')

    def test016_filter_by_testplan_number(self):
        """
        User can filter with testplan number

        LIMS-6473
        """
        self.info("select random test plan")
        random_testplan = random.choice(
            self.test_plan_api.get_all_test_plans_json())
        self.info("selected_test_plan No {}".format(random_testplan['number']))
        self.test_plan.filter_by_testplan_number(random_testplan['number'])
        testplan_found = self.test_plan.result_table()
        self.assertIn(str(random_testplan['number']),
                      (testplan_found[0].text).replace("'", ""))
        self.info('Filtering by number was done successfully')

    def test017_filter_by_testplan_name(self):
        """
        User can filter with testplan name

        LIMS-6470
        """
        random_testplan = random.choice(
            self.test_plan_api.get_all_test_plans_json())
        self.assertTrue(random_testplan, "can't select random test plan !")
        testplans_found_text = self.test_plan.filter_by_element_and_get_text(
            'Testplan Name', 'test_plans:testplan_name_filter',
            random_testplan['testPlanName'], 'drop_down')

        for tp_text in testplans_found_text:
            self.assertIn(str(random_testplan['testPlanName']),
                          tp_text.replace("'", ""))

    @parameterized.expand(['Completed', 'In Progress'])
    def test018_filter_by_testplan_status(self, status):
        """
        User can filter with status

        LIMS-6474
        """
        testplans_found_text = \
            self.test_plan.filter_by_element_and_get_text('Status', 'test_plans:testplan_status_filter',
                                                          status, 'drop_down')
        for tp_text in testplans_found_text:
            self.assertIn(status, tp_text)
            if status == "In Progress":
                self.assertNotIn('Completed', tp_text)
            else:
                self.assertNotIn('In Progress', tp_text)

    def test019_filter_by_testplan_changed_by(self):
        """
        User can filter with changed by field

        LIMS-6475
        """
        self.login_page = Login()
        self.info('Calling the users api to create a new user with username')
        response, payload = UsersAPI().create_new_user()
        self.assertEqual(response['status'], 1, payload)
        self.test_plan.sleep_tiny()
        self.login_page.logout()
        self.test_plan.sleep_tiny()
        self.login_page.login(username=payload['username'],
                              password=payload['password'])
        self.base_selenium.wait_until_page_url_has(text='dashboard')
        self.test_plan.get_test_plans_page()
        self.test_plan.sleep_tiny()
        testplan_name = self.test_plan.create_new_test_plan()

        self.info('New testplan is created successfully with name: {}'.format(
            testplan_name))
        self.test_plan.set_all_configure_table_columns_to_specific_value(
            value=True)

        testplan_found = self.test_plan.filter_by_element_and_get_results(
            'Changed By', 'test_plans:testplan_changed_by_filter',
            payload['username'], 'drop_down')
        self.assertEqual(len(testplan_found), 2)
        self.assertIn(payload['username'], testplan_found[0].text)
        self.assertIn(testplan_name, testplan_found[0].text)

    def test020_filter_by_testplan_material_type(self):
        """
        User can filter with material type field

        LIMS-6471
        """
        random_testplan = random.choice(
            self.test_plan_api.get_all_test_plans_json())
        testplans_found_text = self.test_plan.filter_by_element_and_get_text(
            'Material Type', 'test_plans:testplan_material_type_filter',
            random_testplan['materialTypes'][0], 'drop_down')

        for tp_text in testplans_found_text:
            self.assertIn(str(random_testplan['materialTypes'][0]), tp_text)

    def test021_filter_by_testplan_article(self):
        """
        User can filter with article field

        LIMS-6472
        """
        random_testplan = random.choice(
            self.test_plan_api.get_all_test_plans_json())
        if random_testplan['article'][0] == 'all':
            testplans_found_text = self.test_plan.filter_by_element_and_get_text(
                'Article', 'test_plans:testplan_article_filter', 'All',
                'drop_down')
        else:
            testplans_found_text = self.test_plan.filter_by_element_and_get_text(
                'Article', 'test_plans:testplan_article_filter',
                random_testplan['articleNo'][0], 'drop_down')

        for tp_text in testplans_found_text:
            self.assertIn(str(random_testplan['article'][0]), tp_text)

    def test022_filter_by_testplan_created_on(self):
        """
        User can filter with created on field

        LIMS-6476
        """
        random_testplan = random.choice(
            self.test_plan_api.get_all_test_plans_json())
        date = datetime.datetime.strptime(random_testplan['createdAt'],
                                          "%Y-%m-%dT%H:%M:%S.%fZ")
        date_formatted = datetime.datetime.strftime(date, '%d.%m.%Y')

        testplans_found_text = self.test_plan.filter_by_element_and_get_text(
            'Created On', 'test_plans:testplan_created_on_filter',
            date_formatted, 'date')

        for tp_text in testplans_found_text:
            self.assertIn(date_formatted, tp_text)

    @parameterized.expand(['ok', 'cancel'])
    def test023_create_approach_overview_button(self, ok):
        """
        Master data: Create: Overview button Approach: Make sure
        after I press on the overview button, it redirects me to the active table

        LIMS-6203
        """
        self.info("click on create test plan button")
        self.test_plan.click_create_test_plan_button()
        self.info("click on Overview, this will display an alert to the user")
        self.test_plan.click_overview()
        # switch to the alert
        if 'ok' == ok:
            self.info("confirm pop-up")
            self.test_plan.confirm_overview_pop_up()
            self.assertEqual(self.base_selenium.get_url(),
                             '{}testPlans'.format(self.base_selenium.url))
            self.info('clicking on Overview confirmed')
        else:
            self.info("cancel pop-up")
            self.test_plan.cancel_overview_pop_up()
            self.assertEqual(self.base_selenium.get_url(),
                             '{}testPlans/add'.format(self.base_selenium.url))
            self.info('clicking on Overview cancelled')

    def test024_edit_approach_overview_button(self):
        """
        Edit: Overview Approach: Make sure after I press on
        the overview button, it redirects me to the active table

        LIMS-6202
        """
        testplan = random.choice(self.test_plan_api.get_all_test_plans_json())
        self.info('Navigate to edit page of test plan: {} '.format(
            testplan['testPlanName']))
        self.test_plan.get_test_plan_edit_page_by_id(testplan['id'])
        testplans_url = self.base_selenium.get_url()
        self.info('testplans_url : {}'.format(testplans_url))
        self.info('click on Overview, it will redirect you to test plans page')
        self.test_plan.click_overview()
        self.test_plan.sleep_tiny()
        self.assertEqual(self.base_selenium.get_url(),
                         '{}testPlans'.format(self.base_selenium.url))
        self.info('clicking on Overview confirmed')

    def test025_testplans_search_then_navigate(self):
        """
        Search Approach: Make sure that you can search then navigate to any other page

        LIMS-6201
        """
        testplan = random.choice(self.test_plan_api.get_all_test_plans_json())
        search_results = self.test_plan.search(testplan['testPlanName'])
        self.assertGreater(
            len(search_results), 1,
            " * There is no search results for it, Report a bug.")
        # Navigate to articles page
        self.info('navigate to articles page')
        Articles().get_articles_page()
        self.assertEqual(self.base_selenium.get_url(),
                         '{}articles'.format(self.base_selenium.url))

    def test026_hide_all_table_configurations(self):
        """
        Table configuration: Make sure that you can't hide all the fields from the table configuration

        LIMS-6288
        """
        self.assertFalse(self.test_plan.deselect_all_configurations())

    def test027_test_unit_update_version_in_testplan(self):
        """
        Test plan: Test unit Approach: In case I update category & iteration of
        test unit that used in test plan with new version, when  go to test plan
        to add the same test unit , I found category & iteration updated

        LIMS-3703
        """
        self.test_unit_page = TstUnit()
        self.info("select random test unit to create the test plan with it")
        testunit = random.choice(TestUnitAPI().get_testplan_valid_test_unit())

        self.info(
            'A random test unit is chosen, its name: {}, category: {} and number of iterations: {}'
            .format(testunit['name'], testunit['categoryName'],
                    testunit['iterations']))

        self.info("create the first testplan")
        first_testplan_name, payload1 = self.test_plan_api.create_testplan()
        self.info('First test plan create with name: {}'.format(
            payload1['testPlan']['text']))

        self.info(
            "go to testplan edit to get the number of iterations and test unit category"
        )
        first_testplan_testunit_category, first_testplan_testunit_iteration = \
            self.test_plan.get_testunit_category_iterations(payload1['testPlan']['text'], testunit['name'])

        self.info(
            "go to test units' active table and search for this test unit")
        self.test_unit_page.get_test_units_page()
        self.info('Navigating to test unit {} edit page'.format(
            testunit['name']))
        self.test_unit_page.open_test_unit_edit_page_by_id(testunit['id'])
        self.test_unit_page.sleep_small()
        new_iteration = str(int(first_testplan_testunit_iteration) + 1)
        new_category = self.generate_random_string()
        self.info("update the iteration to {} and category to {}".format(
            new_iteration, new_category))
        self.test_unit_page.set_category(new_category)
        self.test_unit_page.set_testunit_iteration(new_iteration)
        self.info("press save and complete to create a new version")
        self.test_unit_page.save_and_create_new_version()

        self.info(" go back to test plans active table")
        self.test_plan.get_test_plans_page()
        self.info(
            " create new testplan with this testunit after creating the new version"
        )
        response, payload2 = self.test_plan_api.create_testplan()
        self.assertEqual(response["status"], 1)
        second_testplan_name = payload2['testPlan']['text']
        self.info('Second test plan create with name: {}'.format(
            second_testplan_name))

        self.info(
            "check the iteration and category to be the same as the new version"
        )
        self.info(
            "go to testplan edit to get the number of iterations and testunit category"
        )
        second_testplan_testunit_category, second_testplan_testunit_iteration = \
            self.test_plan.get_testunit_category_iterations(second_testplan_name, testunit['name'])

        self.info(
            'Asserting that the category of the test unit in the first test plan is not updated'
        )
        self.assertNotEqual(first_testplan_testunit_category, new_category)
        self.info(
            'Asserting that the iterations of the test unit in the first test plan is not updated'
        )
        self.assertNotEqual(first_testplan_testunit_iteration,
                            second_testplan_testunit_iteration)
        self.info(
            'Asserting that the category of the test unit in the second new_iteration is the '
            'same as the updated category')
        self.assertEqual(second_testplan_testunit_category, new_category)
        self.info(
            'Asserting that the iterations of the test unit in the second testplan is the '
            'same as the updated iterations')
        self.assertEqual(second_testplan_testunit_iteration, new_iteration)

    def test028_childtable_limits_of_quantification(self):
        """
        Limits of quantification should be viewed in the testplan's child table

        LIMS-4179

        New: Test plan: Limits of quantification Approach: In case I update the limits
        of quantification this will trigger new version in the active table & version table

        LIMS-4426
        """
        self.info(
            "Create new quantitative test unit with quantification limits")
        self.test_unit_api = TestUnitAPI()
        oldUpperLimit = self.generate_random_number(lower=50, upper=100)
        oldLowerLimit = self.generate_random_number(lower=1, upper=49)
        tu_response, tu_payload = self.test_unit_api.create_quantitative_testunit(
            quantificationUpperLimit=oldUpperLimit,
            quantificationLowerLimit=oldLowerLimit,
            useQuantification=True,
            useSpec=False)
        self.assertEqual(tu_response['status'], 1, tu_payload)
        testunit_display_old_quantification_limit = '{}-{}'.format(
            tu_payload['quantificationLowerLimit'],
            tu_payload['quantificationUpperLimit'])

        test_plan = self.test_plan_api.create_testplan_from_test_unit_id(
            tu_response['testUnit']['testUnitId'])
        self.assertTrue(test_plan, "failed to create test plan")
        testplan_childtable_data = self.test_plan.search_and_get_childtable_data_for_testplan(
            test_plan['testPlanEntity']['name'])
        self.info('Asserting the limits of quantification viewed correctly')
        self.assertIn(testunit_display_old_quantification_limit,
                      testplan_childtable_data[0].values())

        new_quantification_lower_limit, new_quantification_upper_limit = \
            self.test_plan.update_upper_lower_limits_of_testunit(test_plan['id'])

        testunit_display_new_quantification_limit = '{}-{}'.format(
            new_quantification_lower_limit, new_quantification_upper_limit)

        self.test_plan.get_test_plans_page()
        testplan_childtable_data = self.test_plan.search_and_get_childtable_data_for_testplan(
            test_plan['testPlanEntity']['name'])
        self.info('Asserting the limits of quantification viewed correctly')
        self.assertIn(testunit_display_new_quantification_limit,
                      testplan_childtable_data[0].values())
        test_plan_data = self.test_plan.get_the_latest_row_data()
        self.info('Asserting that new version created')
        self.assertEqual(test_plan_data['Version'], '2')
コード例 #11
0
    def test051_test_unit_name_allow_user_to_search_with_selected_two_options_order(self, first_search_option,
                                                                                    second_search_option):
        """
        Test Unit: Configuration: Test units Name Approach: When the user select any two options
        from the test unit configuration, this action should reflect on the order form

        LIMS-6672

        Orders: Default filter test unit Approach: Allow the search criteria in the drop down list
        in the filter section to be same as in the form

        LIMS-7414
        """
        options_exist = {}
        order_page = Order()
        self.test_unit_page.open_configurations()
        self.test_unit_page.open_testunit_name_configurations_options()
        self.test_unit_page.select_option_to_view_search_with(
            view_search_options=[first_search_option, second_search_option])

        self.info('create new quantitative test unit with unit and quantification')
        response, payload = self.test_unit_api.create_quantitative_testunit(
            useSpec=False, useQuantification=True, unit='m[g]{o}',
            quantificationUpperLimit=self.generate_random_number(lower=50, upper=100),
            quantificationLowerLimit=self.generate_random_number(lower=1, upper=49))
        self.assertEqual(response['status'], 1, payload)
        quantification_limit = '{}-{}'.format(payload['quantificationLowerLimit'],
                                              payload['quantificationUpperLimit'])
        self.info('new test unit created with number  {}'.format(payload['number']))

        self.info('get random order')
        radndom_order = random.choice(OrdersAPI().get_all_orders_json())
        self.assertTrue(radndom_order, 'No order selected')
        self.info('navigate to order edit page')
        order_page.get_order_edit_page_by_id(radndom_order['orderId'])
        order_page.sleep_small()

        if first_search_option == "Type":
            if second_search_option == "Method":
                checked_text = f'Quantitative: {payload["method"]}'
            elif second_search_option == "No":
                checked_text = f'Quantitative: {payload["number"]}'
        else:
            checked_text = f'{payload["name"]}: Quantitative'

        self.info("is test unit options existing?")
        options_exist['is_name_exist'] = order_page.is_test_unit_option_exist(search_field=payload['name'])
        options_exist['is_no_exist'] = order_page.is_test_unit_option_exist(search_field=str(payload['number']))
        options_exist['is_type_exist'] = order_page.is_test_unit_option_exist(search_field='Quantitative',
                                                                              checked_text=checked_text)
        options_exist['is_method_exist'] = order_page.is_test_unit_option_exist(search_field=payload['method'])
        options_exist['is_unit_exist'] = order_page.is_test_unit_option_exist(search_field=payload['unit'])
        options_exist['is_quantification_limit_exist'] = order_page.is_test_unit_option_exist(
            search_field=quantification_limit)

        for key, value in options_exist.items():
            if (first_search_option.lower().replace(' ', '_') in key) or (len(second_search_option.lower()) > 0 and second_search_option.lower() in key):
                self.assertTrue(value, f'{key} value should be True')
            else:
                self.assertFalse(value, f'{key} value should be False')