Ejemplo n.º 1
0
    def __load_po_class(self, path):
        self.table_and_test_file_tabs.table.clear_table()

        if not os.path.exists(path):
            show_dialog_path_doesnt_exist(self, path)
        if not is_correct_python_file(path):
            show_dialog(self, u'File name is incorrect: %s' % path,
                        u'Bad file name')
        else:
            folder = os.path.dirname(path)
            files = [os.path.join(folder, p) for p in os.listdir(folder)
                     if is_correct_python_file(p)]
            self.cb_class_path.Clear()
            self.cb_class_path.AppendItems(files)
            self.cb_class_path.Select(files.index(path))
            try:
                self.__cur_po_class = PageObjectClass.parse_string_to_po_class(read_file(path))
                area = self.__cur_po_class.area
                self.image_panel.set_po_fields(self.__cur_po_class.fields)
                self.image_panel.load_image(self.__cur_po_class.img_path, area)

                self.cb_class_path.SetValue(self.__cur_po_class.file_path)

                self.table_and_test_file_tabs.load_po_class(self.__cur_po_class)
            except Exception:
                self.__cur_po_class = None
                show_error_dialog(self, traceback.format_exc(),
                                  u'Failed to open file %s' % path)
 def test_get_file_content(self):
     if is_windows():
         self.skipTest(
             'Unsupported in Windows because temp directory is hardcoded to \'/tmp\' in pickled object.'
         )
     else:
         expected_string = read_file(self.expected_duckduckgo_class_path)
         self.assertEqual(self.po_class_object._get_file_content().strip(),
                          expected_string.strip())
Ejemplo n.º 3
0
 def test_get_file_content(self):
     if is_windows():
         self.skipTest(
             'Unsupported in Windows because temp directory is hardcoded to \'/tmp\' in pickled object.'
         )
     else:
         expected_string = read_file(self.expected_duckduckgo_class_path)
         self.assertEqual(
             self.po_class_object._get_file_content().strip(),
             expected_string.strip()
         )
    def test_parse_string_to_po_class(self):
        if is_windows():
            self.skipTest(
                "Unsupported in Windows because temp directory is hardcoded to '/tmp' in pickled object."
            )
        else:
            expected_string = read_file(self.expected_duckduckgo_class_path)
            self.assertEqual(self.po_class_object._get_file_content().strip(),
                             expected_string.strip())
            po_class = PageObjectClass.parse_string_to_po_class(
                read_file(self.expected_duckduckgo_class_path))

            self.assertEqual(po_class.name, self.po_class_object.name)
            self.assertEqual(po_class.url, self.po_class_object.url)
            self.assertEqual(po_class.fields, self.po_class_object.fields)
            self.assertEqual(po_class.area, self.po_class_object.area)
            self.assertEqual(po_class.file_path,
                             self.po_class_object.file_path)
            self.assertEqual(po_class.img_path, self.po_class_object.img_path)

            self.assertEqual(po_class, self.po_class_object)
Ejemplo n.º 5
0
    def test_parse_string_to_po_class(self):
        if is_windows():
            self.skipTest(
                "Unsupported in Windows because temp directory is hardcoded to '/tmp' in pickled object."
            )
        else:
            expected_string = read_file(self.expected_duckduckgo_class_path)
            self.assertEqual(
                self.po_class_object._get_file_content().strip(),
                expected_string.strip()
            )
            po_class = PageObjectClass.parse_string_to_po_class(
                read_file(self.expected_duckduckgo_class_path)
            )

            self.assertEqual(po_class.name, self.po_class_object.name)
            self.assertEqual(po_class.url, self.po_class_object.url)
            self.assertEqual(po_class.fields, self.po_class_object.fields)
            self.assertEqual(po_class.area, self.po_class_object.area)
            self.assertEqual(po_class.file_path,
                             self.po_class_object.file_path)
            self.assertEqual(po_class.img_path, self.po_class_object.img_path)

            self.assertEqual(po_class, self.po_class_object)