Пример #1
0
    def setUp(self):
        self.filename = "uupyshell.txt"
        self.result_filename = environ["MYHOME"] + "\\pyshell_result.txt"
        self.datasp = DataStoredProc(path.join(TESTDIR, TESTDBNAME))
        self.encoding = "uu"
        self.columns = [
            "idStudent", "sStudentFirstNm", "sStudentLastNm", "idPrep",
            "iGradeLevel"
        ]
        self.column_defn = [('col1', 'text'), ('col2', 'text'),
                            ('col3', 'integer')]
        self.rows = [[666, 'foo', 'bar', 2, 6], [667, 'blah', 'blah', 3, 6]]
        self.row = ['idPrep', 3, 'idStudent', 666]

        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")

        append_text_to_file(
            self.filename,
            "sp_name:" + encode("insert_student", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "columns:" + "$$".join([field for field in self.columns]) + "\n")

        put_2darray_in_file(self.filename, self.rows, suffix="rows:")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)
        DataStoredProc.sp_args = {}
Пример #2
0
    def test_(self):

        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "sp_name:" + encode("student_schedule", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "header_flag:" + encode("True", self.encoding) + "\n")
        append_text_to_file(
            self.filename, "sp_args:" + encode(
                "<root><students>70</students><days>M</days><periods>1</periods></root>",
                self.encoding) + "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)
        self.assertEqual(result, [[
            'sSubjectLongDesc', 'sCourseNm', 'sClassFocusArea',
            'sFacultyFirstNm', 'cdDay', 'idTimePeriod', 'idLocation',
            'idSection', 'cdClassType', 'iFreq', 'idClassLecture'
        ],
                                  [
                                      u'Homeroom', u'Homeroom', None, u'Isaac',
                                      u'M', 1, 9, 165, u'Seminar', 5, 993
                                  ]])

        self.assertTrue(os_file_exists(self.result_filename))
        self.assertEqual(
            "sSubjectLongDesc^sCourseNm^sClassFocusArea^sFacultyFirstNm^cdDay^idTimePeriod^idLocation^idSection^cdClassType^iFreq^idClassLecture$$Homeroom^Homeroom^None^Isaac^M^1^9^165^Seminar^5^993",
            os_file_to_string(self.result_filename))
Пример #3
0
    def test_(self):
        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "sp_name:" + encode("student_schedule", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename, "sp_args:" + encode(
                "<root><students>70</students><days>M</days><periods>1</periods></root>",
                self.encoding) + "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)
        self.assertEqual(result, [[
            u'Homeroom', u'Homeroom', None, u'Isaac', u'M', 1, 9, 165,
            u'Seminar', 5, 993
        ]])

        self.assertTrue(os_file_exists(self.result_filename))
        self.assertEqual(
            "Homeroom^Homeroom^None^Isaac^M^1^9^165^Seminar^5^993",
            os_file_to_string(self.result_filename))
Пример #4
0
 def setUp(self):
     super(Test_GitCCreateCommit, self).setUp()
     self.filename = environ["MYHOME"] + "\\testpygithub\\git_test.txt"
     write_text_to_file(self.filename, "this is a test")
     self.tree = GitCommitHelper._create_input_tree(self.filename,
                                                    self.repo)
     self.parents = [GitCommitHelper._get_last_commit(self.repo)]
Пример #5
0
    def tearDown(self):

        write_text_to_file(environ["MYHOME"] + "\\testpygithub\\git_test.txt",
                           "this is a test")
        write_text_to_file(environ["MYHOME"] + "\\testpygithub\\git_test2.txt",
                           "this is a test2")
        super(Test_GitCommitHelperPublic_MultiCommit, self).tearDown()
Пример #6
0
    def test_(self):

        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "sp_name:" + encode("student_schedule", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename, "sp_args:" + encode(
                "<root><students>70</students><students>69</students><days>M</days><days>T</days><periods>1</periods><periods>2</periods></root>",
                self.encoding) + "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)

        expected_results = [[
            u'Homeroom', u'Homeroom', None, u'Samantha', u'M', 1, 10, 163,
            u'Seminar', 5, 983
        ],
                            [
                                u'Homeroom', u'Homeroom', None, u'Isaac', u'M',
                                1, 9, 165, u'Seminar', 5, 993
                            ],
                            [
                                u'Movement', u'Movement', None, u'Michael',
                                u'M', 2, 37, 432, u'Seminar', 1, 1196
                            ],
                            [
                                u'Science', u'Science', None, u'John', u'M', 2,
                                4, 162, u'1on1', 1, 143
                            ],
                            [
                                u'Homeroom', u'Homeroom', None, u'Samantha',
                                u'T', 1, 10, 163, u'Seminar', 5, 984
                            ],
                            [
                                u'Homeroom', u'Homeroom', None, u'Isaac', u'T',
                                1, 9, 165, u'Seminar', 5, 994
                            ],
                            [
                                u'Foreign Language', u'Spanish 1', None,
                                u'Jamie', u'T', 2, 6, 451, u'Seminar', 2, 1218
                            ],
                            [
                                u'Work Period', u'Work Period', None,
                                u'Alyssa', u'T', 2, 37, 564, u'Seminar', 1, 713
                            ]]

        self.assertEqual(result, expected_results)

        self.assertTrue(os_file_exists(self.result_filename))
        self.assertEqual(
            os_file_to_string(self.result_filename),
            "Homeroom^Homeroom^None^Samantha^M^1^10^163^Seminar^5^983$$Homeroom^Homeroom^None^Isaac^M^1^9^165^Seminar^5^993$$Movement^Movement^None^Michael^M^2^37^432^Seminar^1^1196$$Science^Science^None^John^M^2^4^162^1on1^1^143$$Homeroom^Homeroom^None^Samantha^T^1^10^163^Seminar^5^984$$Homeroom^Homeroom^None^Isaac^T^1^9^165^Seminar^5^994$$Foreign Language^Spanish 1^None^Jamie^T^2^6^451^Seminar^2^1218$$Work Period^Work Period^None^Alyssa^T^2^37^564^Seminar^1^713"
        )
Пример #7
0
 def setUp(self):
     super(Test_GitCreateRepo,self).setUp()
     self.filename = "uupyshell.txt"
     self.encoding = "uu"
     write_text_to_file(self.filename,"token:"+encode(self.token,self.encoding) + "\n")
     append_text_to_file(self.filename,"reponame:"+encode(self.reponame,self.encoding) + "\n")
     append_text_to_file(self.filename,"username:"******"\n")
     append_text_to_file(self.filename,"gitrootpath:"+encode(self.gitrootpath,self.encoding) + "\n")
Пример #8
0
    def setUp(self):
        super(Test_GitHistory,self).setUp()
        self.filename = "uupyshell.txt"
        self.encoding = "uu"
        self.user = GitBase._get_user(self.github)
        self.repo = GitRepoHelper._create_repo(self.user,self.reponame,auto_init=True)        
        write_text_to_file(self.filename,"token:"+encode(self.token,self.encoding) + "\n")
        append_text_to_file(self.filename,"reponame:"+encode(self.reponame,self.encoding) + "\n")
        append_text_to_file(self.filename,"gitrootpath:"+encode(self.gitrootpath,self.encoding) + "\n")
        append_text_to_file(self.filename,"commit_message:"+encode(self.commit_message,self.encoding) + "\n")
        append_text_to_file(self.filename,"commit_files:"+"$$".join([encode(_file,self.encoding) for _file in self.commit_files]) + "\n")

        GitCommitHelper.commit(self.token,self.reponame,self.commit_files,self.commit_message)
Пример #9
0
    def setUp(self):
        super(Test_GitUpdateRefs, self).setUp()
        self.filename = environ["MYHOME"] + "\\testpygithub\\git_test.txt"
        write_text_to_file(self.filename, "this is a test")
        self.parents = [GitCommitHelper._get_last_commit(self.repo)]

        self.base_tree = self.parents[0]._tree.value

        self.tree = GitCommitHelper._create_input_tree(
            self.filename, self.repo, base_tree=self.base_tree)
        self.git_commit = GitCommitHelper._create_commit(
            self.repo, "commit via pyyhon api", self.tree, self.parents)
        self.headref = GitCommitHelper._get_ref(self.repo)
Пример #10
0
 def setUp(self):
     super(Test_GitCommit2Levels,self).setUp()
     
     self.commit_files = self.commit_files + ["C:\\Users\\burtnolej\\testpygithub\\test\\git_test5.txt",
                                              "C:\\Users\\burtnolej\\testpygithub\\test\\git_test6.txt"]
     self.filename = "uupyshell.txt"
     self.encoding = "uu"
     self.user = GitBase._get_user(self.github)
     self.repo = GitRepoHelper._create_repo(self.user,self.reponame,auto_init=True)        
     write_text_to_file(self.filename,"token:"+encode(self.token,self.encoding) + "\n")
     append_text_to_file(self.filename,"reponame:"+encode(self.reponame,self.encoding) + "\n")
     append_text_to_file(self.filename,"gitrootpath:"+encode(self.gitrootpath,self.encoding) + "\n")
     append_text_to_file(self.filename,"commit_message:"+encode(self.commit_message,self.encoding) + "\n")
     append_text_to_file(self.filename,"commit_files:"+"$$".join([encode(_file,self.encoding) for _file in self.commit_files]) + "\n")
Пример #11
0
    def test_(self):
        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")

        append_text_to_file(
            self.filename,
            "sp_name:" + encode("insert_student", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "header_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "columns:" + "$$".join([field for field in self.columns]) + "\n")

        put_2darray_in_file(self.filename, self.row, suffix="rows:")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)

        DataStoredProc.sp_args = {}

        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "sp_name:" + encode("student", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename, "sp_args:" +
            encode("<root><students>667</students></root>", self.encoding) +
            "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)

        self.assertEqual(result, [[u'blah', u'blah', 667, 3, u'Aurora']])
Пример #12
0
    def tearDown(self):
        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")

        append_text_to_file(
            self.filename,
            "sp_name:" + encode("delete_student", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename, "sp_args:" + encode(
                "<root><students>666</students><students>667</students></root>",
                self.encoding) + "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)
        os_file_delete(self.filename)
Пример #13
0
    def test_(self):
        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")

        append_text_to_file(
            self.filename,
            "sp_name:" + encode("update_student", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "row:" + "$$".join([str(field) for field in self.row]) + "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)
        DataStoredProc.sp_args = {}

        write_text_to_file(
            self.filename, "database_name:" +
            encode(path.join(TESTDIR, TESTDBNAME), self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "sp_name:" + encode("student", self.encoding) + "\n")
        append_text_to_file(
            self.filename,
            "delete_flag:" + encode("False", self.encoding) + "\n")
        append_text_to_file(
            self.filename, "sp_args:" +
            encode("<root><students>666</students></root>", self.encoding) +
            "\n")

        result = DataStoredProc.stored_proc_by_file(
            self.filename, result_file=self.result_filename)

        self.assertEqual(result, [[u'foo', u'bar', 666, 3, u'Aurora']])
Пример #14
0
 def _create_output_file(self, filepath, input_rows, encoding="unicode"):
     outstr = "$$".join(["^".join(map(str, _row)) for _row in input_rows])
     write_text_to_file(filepath, outstr)
Пример #15
0
 def setUp(self):
     super(Test_GitCCreateInputTree, self).setUp()
     self.filename = environ["MYHOME"] + "\\testpygithub\\git_test.txt"
     write_text_to_file(self.filename, "this is a test")
Пример #16
0
 def tearDown(self):
     write_text_to_file(self.filename, "this is a test")
     super(Test_GitMultiUpdateRefs, self).tearDown()