示例#1
0
    def test_rec_child_folders__anweb(self):
        """
        These tests will fail unless the specific file is on your computer
            in the specific place indicated by `test_file_path`
        NOTE: This file is NOT static, thus this test is bound to fail over
            time. IF it fails, then check to make sure there isn't a bug in
            this project.
            * If there is a bug, then fix it and make this test
                passing.
            * If there is no bug, then just make this test pass again
        """
        from parsefilelib.models.file_obj import FileObj
        from parsefilelib.models.folder_obj import FolderObj

        test_folder_path = '/opt/webapp/anweb/src/anweb/anweb/'
        folder_obj = FolderObj(test_folder_path)

        assert folder_obj.name == 'anweb'
        assert len(folder_obj.folders) == 5

        assert len(folder_obj.files) == 2

        test_file_path = '/opt/webapp/anweb/src/anweb/anweb/models/surveys.py'
        file_obj = FileObj(file_path=test_file_path)
        output_to_file('/opt/webapp/proflib_visualizer/src/proflib_visualizer/proflib_visualizer/static/json/parse_file_lib_json_files/test_2.json',
                        [folder_obj.to_dict()],
                        append=False)

        """
示例#2
0
    def test_dict_write_simple(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_dict_write_simple.txt')

        output = {'a': 'cool'}

        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 3)
        finally:
            self._clean_up_file(file_path)
示例#3
0
    def test_simple_append(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_simple_append.txt')

        output = "This is a test\n"

        output_to_file(file_path, output, append=True)

        try:
            self._assert_length(file_path, 1)
        finally:
            self._clean_up_file(file_path)
示例#4
0
    def test_row_proxy_write_simple(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_obj_write_obj_inside_another.txt')

        output = RowProxy(test='test', test2= 45)

        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 4)
        finally:
            self._clean_up_file(file_path)
示例#5
0
    def test_object_write_obj_2_inside_another(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_obj_write_obj_2_inside_another.txt')

        output = TObject(test='test', test2= {'c': '45'}, test3= {'d': {'e': 1, 'f': '3'}})

        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 12)
        finally:
            self._clean_up_file(file_path)
示例#6
0
    def test_list_write_obj_inside(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_list_write_simple.txt')

        output = ['1', '2', TObject(test='test')]

        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 7)
        finally:
            self._clean_up_file(file_path)
示例#7
0
    def test_dict_write_one_inside_another_with_int_value(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_dict_write_one_inside_another.txt')

        output = {'a': 'cool', 'b': {'c': 45}}

        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 6)
        finally:
            self._clean_up_file(file_path)
示例#8
0
    def test_simple_write_twice(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_simple_write_twice.txt')

        output = 'This is a test\n'

        output_to_file(file_path, output)
        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 1)
        finally:
            self._clean_up_file(file_path)
示例#9
0
    def test_row_proxy_write_list(self):
        from outlib.lib.wout import output_to_file
        file_path = "%s%s" % (test_file_directory, 'test_obj_write_obj_inside_another.txt')

        output = []
        output.append(RowProxy(key1='test1', key11= 1))
        output.append(RowProxy(key2='test2', key22= '45'))
        output.append(RowProxy(key3='test3', key33= 3))

        output_to_file(file_path, output)

        try:
            self._assert_length(file_path, 14)
        finally:
            self._clean_up_file(file_path)