コード例 #1
0
 def setUp(self):
     self.correct_git_address = "https://github.com/JunoJunho/AutoDoTestApp"
     self.wrong_git_address = "https://jithub.com/JunoJunho/AutoDoTestApp"
     self.project_name = "AutoDoTestApp"
     self.p = Parser()
     git_dir = os.path.join(settings.BASE_DIR, "git_project")
     if not os.path.exists(git_dir):
         os.mkdir(git_dir)
コード例 #2
0
 def __init__(self):
     self.parser = Parser()
     self.generator = Generator()
     self.task_q = Queue()
     self.result_q = Queue()
     self.threads = []
     self.proj_desc = ""
     for method in [self.parse_project, self.generate_document]:
         t = threading.Thread(target=method)
         t.daemon = True
         print("Method " + str(method) + " started")
         self.threads.append(t)
         t.start()
コード例 #3
0
 def setUp(self):
     self.p = Parser()
     self.g = Generator()
     self.test_git_url = "https://github.com/JunoJunho/AutoDoTestApp"
     self.result = self.p.parse_project(self.test_git_url)
     self.project_description = "Test description"
     self.g.generate_document(data=self.result[0],
                              name=self.result[1],
                              raw_api=self.result[2],
                              desc=self.project_description,
                              licen=self.result[4],
                              req=self.result[3])
     self.result_directory = os.path.join(settings.BASE_DIR,
                                          "parsing_result")
     self.project_name = "AutoDoTestApp"
     self.git_directory = os.path.join(settings.BASE_DIR, "git_project")
     self.file_loc = os.path.join(self.result_directory, self.project_name)
コード例 #4
0
    def setUp(self):

        self.git_address = "https://github.com/JunoJunho/AutoDoTestApp"
        self.project_name = "AutoDoTestApp"
        self.p = Parser()
        self.test_graph = Generator()
        self.test_readme = Generator()
        self.test_api = Generator()
        self.test_document = Generator()
        #self.client = Client()
        self.parsing_dir = os.path.join(settings.BASE_DIR, "parsing_result")
        if not os.path.exists(self.parsing_dir):
            os.mkdir(self.parsing_dir)

        git_dir = os.path.join(settings.BASE_DIR, "git_project")
        if not os.path.exists(git_dir):
            os.mkdir(git_dir)
コード例 #5
0
ファイル: tests.py プロジェクト: AutoDo/AutoDo
 def setUp(self):
     self.correct_git_address = "https://github.com/JunoJunho/AutoDoTestApp"
     self.wrong_git_address = "https://jithub.com/JunoJunho/AutoDoTestApp"
     self.project_name = "AutoDoTestApp"
     self.p = Parser()
     git_dir = os.path.join(settings.BASE_DIR, "git_project")
     if not os.path.exists(git_dir):
         os.mkdir(git_dir)
コード例 #6
0
ファイル: Manager.py プロジェクト: AutoDo/AutoDo
 def __init__(self):
     self.parser = Parser()
     self.generator = Generator()
     self.task_q = Queue()
     self.result_q = Queue()
     self.threads = []
     self.proj_desc = ""
     for method in [self.parse_project, self.generate_document]:
         t = threading.Thread(target=method)
         t.daemon = True
         print("Method " + str(method) + " started")
         self.threads.append(t)
         t.start()
コード例 #7
0
class ParserTestCase(TestCase):
    def setUp(self):
        self.correct_git_address = "https://github.com/JunoJunho/AutoDoTestApp"
        self.wrong_git_address = "https://jithub.com/JunoJunho/AutoDoTestApp"
        self.project_name = "AutoDoTestApp"
        self.p = Parser()
        git_dir = os.path.join(settings.BASE_DIR, "git_project")
        if not os.path.exists(git_dir):
            os.mkdir(git_dir)

    def test_wrong_git_address_should_raise_value_error(self):
        self.assertRaises(ValueError, self.p.parse_project,
                          self.wrong_git_address)

    def test_should_return_tuple(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result, tuple)

    def test_should_return_tuple_with_existing_directory(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result, tuple)

    def test_tuple_length_should_be_5(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertEqual(len(result), 5)

    def test_project_name_is_correct(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertEqual(self.project_name, result[1])

    def test_requirement_list_is_list_type(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result[3], list)

    def test_api_is_dict_type(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result[2], dict)

    def test_license_should_be_MIT(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertTrue("MIT" in result[4])

    def test_graph_is_list_type(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result[0], list)
コード例 #8
0
ファイル: tests.py プロジェクト: AutoDo/AutoDo
class ParserTestCase(TestCase):

    def setUp(self):
        self.correct_git_address = "https://github.com/JunoJunho/AutoDoTestApp"
        self.wrong_git_address = "https://jithub.com/JunoJunho/AutoDoTestApp"
        self.project_name = "AutoDoTestApp"
        self.p = Parser()
        git_dir = os.path.join(settings.BASE_DIR, "git_project")
        if not os.path.exists(git_dir):
            os.mkdir(git_dir)

    def test_wrong_git_address_should_raise_value_error(self):
        self.assertRaises(ValueError, self.p.parse_project, self.wrong_git_address)

    def test_should_return_tuple(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result, tuple)

    def test_should_return_tuple_with_existing_directory(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result, tuple)

    def test_tuple_length_should_be_5(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertEqual(len(result), 5)

    def test_project_name_is_correct(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertEqual(self.project_name, result[1])

    def test_requirement_list_is_list_type(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result[3], list)

    def test_api_is_dict_type(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result[2], dict)

    def test_license_should_be_MIT(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertTrue("MIT" in result[4])

    def test_graph_is_list_type(self):
        result = self.p.parse_project(git_url=self.correct_git_address)
        self.assertIsInstance(result[0], list)
コード例 #9
0
 def setUp(self):
     self.p = Parser()
     self.g = Generator()
     self.test_git_url = "https://github.com/JunoJunho/AutoDoTestApp"
     self.result = self.p.parse_project(self.test_git_url)
     self.project_description = "Test description"
     self.g.generate_document(data=self.result[0],
                              name=self.result[1],
                              raw_api=self.result[2],
                              desc=self.project_description,
                              licen=self.result[4],
                              req=self.result[3])
     self.result_directory = os.path.join(settings.BASE_DIR, "parsing_result")
     self.project_name = "AutoDoTestApp"
     self.git_directory = os.path.join(settings.BASE_DIR, "git_project")
     self.file_loc = os.path.join(self.result_directory, self.project_name)
コード例 #10
0
ファイル: tests.py プロジェクト: AutoDo/AutoDo
    def setUp(self):

        self.git_address = "https://github.com/JunoJunho/AutoDoTestApp"
        self.project_name = "AutoDoTestApp"
        self.p = Parser()
        self.test_graph = Generator()
        self.test_readme = Generator()
        self.test_api = Generator()
        self.test_document = Generator()
        #self.client = Client()
        self.parsing_dir = os.path.join(settings.BASE_DIR, "parsing_result")
        if not os.path.exists(self.parsing_dir):
            os.mkdir(self.parsing_dir)

        git_dir = os.path.join(settings.BASE_DIR, "git_project")
        if not os.path.exists(git_dir):
            os.mkdir(git_dir)
コード例 #11
0
ファイル: Manager.py プロジェクト: AutoDo/AutoDo
class ManagerThread(object):

    def __init__(self):
        self.parser = Parser()
        self.generator = Generator()
        self.task_q = Queue()
        self.result_q = Queue()
        self.threads = []
        self.proj_desc = ""
        for method in [self.parse_project, self.generate_document]:
            t = threading.Thread(target=method)
            t.daemon = True
            print("Method " + str(method) + " started")
            self.threads.append(t)
            t.start()

    def put_request(self, req, desc):
        self.proj_desc = desc
        self.task_q.put(req)

    def parse_project(self):
        # Need to process get project url using github id and project id
        while True:
            if not self.task_q.empty():
                tu = self.parser.parse_project(self.task_q.get())
                self.result_q.put(tu)
                break

    def generate_document(self):
        while True:
            if not self.result_q.empty():
                re = self.result_q.get()
                self.generator.generate_document(data=re[0],
                                                 name=re[1],
                                                 raw_api=re[2],
                                                 desc=self.proj_desc,
                                                 licen=re[4],
                                                 req=re[3])
                break
コード例 #12
0
class ManagerThread(object):
    def __init__(self):
        self.parser = Parser()
        self.generator = Generator()
        self.task_q = Queue()
        self.result_q = Queue()
        self.threads = []
        self.proj_desc = ""
        for method in [self.parse_project, self.generate_document]:
            t = threading.Thread(target=method)
            t.daemon = True
            print("Method " + str(method) + " started")
            self.threads.append(t)
            t.start()

    def put_request(self, req, desc):
        self.proj_desc = desc
        self.task_q.put(req)

    def parse_project(self):
        # Need to process get project url using github id and project id
        while True:
            if not self.task_q.empty():
                tu = self.parser.parse_project(self.task_q.get())
                self.result_q.put(tu)
                break

    def generate_document(self):
        while True:
            if not self.result_q.empty():
                re = self.result_q.get()
                self.generator.generate_document(data=re[0],
                                                 name=re[1],
                                                 raw_api=re[2],
                                                 desc=self.proj_desc,
                                                 licen=re[4],
                                                 req=re[3])
                break
コード例 #13
0
class IntegrationTestCase(TestCase):

    def setUp(self):
        self.p = Parser()
        self.g = Generator()
        self.test_git_url = "https://github.com/JunoJunho/AutoDoTestApp"
        self.result = self.p.parse_project(self.test_git_url)
        self.project_description = "Test description"
        self.g.generate_document(data=self.result[0],
                                 name=self.result[1],
                                 raw_api=self.result[2],
                                 desc=self.project_description,
                                 licen=self.result[4],
                                 req=self.result[3])
        self.result_directory = os.path.join(settings.BASE_DIR, "parsing_result")
        self.project_name = "AutoDoTestApp"
        self.git_directory = os.path.join(settings.BASE_DIR, "git_project")
        self.file_loc = os.path.join(self.result_directory, self.project_name)

    def test_graph_file_is_generated(self):
        self.assertTrue(os.path.exists(self.file_loc + ".png"))

    def test_read_me_is_generated(self):
        self.assertTrue(os.path.exists(self.file_loc + ".md"))
コード例 #14
0
class IntegrationTestCase(TestCase):
    def setUp(self):
        self.p = Parser()
        self.g = Generator()
        self.test_git_url = "https://github.com/JunoJunho/AutoDoTestApp"
        self.result = self.p.parse_project(self.test_git_url)
        self.project_description = "Test description"
        self.g.generate_document(data=self.result[0],
                                 name=self.result[1],
                                 raw_api=self.result[2],
                                 desc=self.project_description,
                                 licen=self.result[4],
                                 req=self.result[3])
        self.result_directory = os.path.join(settings.BASE_DIR,
                                             "parsing_result")
        self.project_name = "AutoDoTestApp"
        self.git_directory = os.path.join(settings.BASE_DIR, "git_project")
        self.file_loc = os.path.join(self.result_directory, self.project_name)

    def test_graph_file_is_generated(self):
        self.assertTrue(os.path.exists(self.file_loc + ".png"))

    def test_read_me_is_generated(self):
        self.assertTrue(os.path.exists(self.file_loc + ".md"))
コード例 #15
0
            #graph.add_edge(edge)
            graph.edge(data[i][0], data[i][1], label=data[i][2], minlen='7')
        # ok, we are set, let's save our graph into a file

        self.png_dir = os.path.join(settings.BASE_DIR, "parsing_result")
        #self.png_dir = os.path.join(self.png_dir, name)
        if os.path.isfile(os.path.join(self.png_dir , name) +".png"):
            os.remove(os.path.join(self.png_dir, name) + ".png")

        #graph.write_png(self.png_dir + '.png')

        graph.render(filename=name, directory=self.png_dir, view=False,cleanup=True)
        cloudinary.config(
            cloud_name="jin8",
            api_key="179139842767459",
            api_secret="BtqQQ54EvWJ8U4TKePyUvFk8kkU"
        )
        response = cloudinary.uploader.upload(os.path.join(self.png_dir, name) + '.png', public_id=name)
        self.url = response['url']
        #print(self.url)


if __name__ == "__main__":
    from AutoDoApp.parser.Parser import Parser

    p = Parser()
    re = p.parse_project(git_url="https://github.com/JunoJunho/AutoDoAppTest")
    g = Generator()
    g.generate_document(re[0], re[1])

コード例 #16
0
ファイル: tests.py プロジェクト: AutoDo/AutoDo
class GeneratorTestCase(TestCase):

    def setUp(self):

        self.git_address = "https://github.com/JunoJunho/AutoDoTestApp"
        self.project_name = "AutoDoTestApp"
        self.p = Parser()
        self.test_graph = Generator()
        self.test_readme = Generator()
        self.test_api = Generator()
        self.test_document = Generator()
        #self.client = Client()
        self.parsing_dir = os.path.join(settings.BASE_DIR, "parsing_result")
        if not os.path.exists(self.parsing_dir):
            os.mkdir(self.parsing_dir)

        git_dir = os.path.join(settings.BASE_DIR, "git_project")
        if not os.path.exists(git_dir):
            os.mkdir(git_dir)


    #invalid wrong valid
    def test_invalid_input_graph(self):
        #result = self.p.parse_project(git_url=self.correct_git_address)

        test_data = [("class A", "class A", "method1"),("class B", "class 1", "method2"),("class C",)]
        self.assertRaises(ValueError, self.test_graph.generate_graph, test_data,"TestInvalidInputGraph")

    def test_valid_input_graph(self):
        file_name = "TestValidGraph"
        test_data = [("class A", "class A", "method1"), ("class B", "class 1", "method2"), ("class C","class A","method3")]
        url = self.test_graph.generate_graph(test_data, "TestValidGraph")
        request = requests.get(url)
        self.assertTrue(request.status_code == 200)

    def test_invalid_name_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md, [], "test","test",[])

    def test_invalid_desc_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md, "TestInvalidReadme", [], "test", [])

    def test_invalid_licen_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md, "TestInvalidReadme", "test", [], [])

    def test_invalid_req_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md, "TestInvalidReadme", "test", "test", "test")

    def test_invalid_url_readme(self):
        self.assertRaises(ValueError, self.test_readme.generate_readme_md, "TestInvalidReadme", "test", "test", [])

    def test_valid_readme(self):
        file_name = "TestValidGraph"
        test_data = [("class A", "class A", "method1"), ("class B", "class A", "method2"),
                     ("class C", "class A", "method3")]
        self.test_readme.generate_graph(test_data, "TestValidGraph")
        self.test_readme.generate_readme_md("TestValidGraph", "test", "test", [])
        self.assertTrue(os.path.isfile(os.path.join(self.parsing_dir,file_name)+".md"))

    def test_invalid_api(self):
        self.assertRaises(TypeError, self.test_api.generate_api, [])

    def test_valid_api(self):
        self.test_api.generate_api({})
        self.assertTrue(True)

    def test_valid_document(self):
        re = self.p.parse_project(self.git_address)
        #generate_document(self, data, name, raw_api, desc, licen, req):
        #tu = [graph, name, self.parse_api(), self.req_list, self.license]
        self.test_document.generate_document(re[0],re[1],re[2],"desc", re[4],re[3])
        self.assertTrue(os.path.isfile(os.path.join(self.parsing_dir,self.project_name)+".md"))
コード例 #17
0
class GeneratorTestCase(TestCase):
    def setUp(self):

        self.git_address = "https://github.com/JunoJunho/AutoDoTestApp"
        self.project_name = "AutoDoTestApp"
        self.p = Parser()
        self.test_graph = Generator()
        self.test_readme = Generator()
        self.test_api = Generator()
        self.test_document = Generator()
        #self.client = Client()
        self.parsing_dir = os.path.join(settings.BASE_DIR, "parsing_result")
        if not os.path.exists(self.parsing_dir):
            os.mkdir(self.parsing_dir)

        git_dir = os.path.join(settings.BASE_DIR, "git_project")
        if not os.path.exists(git_dir):
            os.mkdir(git_dir)

    #invalid wrong valid
    def test_invalid_input_graph(self):
        #result = self.p.parse_project(git_url=self.correct_git_address)

        test_data = [("class A", "class A", "method1"),
                     ("class B", "class 1", "method2"), ("class C", )]
        self.assertRaises(ValueError, self.test_graph.generate_graph,
                          test_data, "TestInvalidInputGraph")

    def test_valid_input_graph(self):
        file_name = "TestValidGraph"
        test_data = [("class A", "class A", "method1"),
                     ("class B", "class 1", "method2"),
                     ("class C", "class A", "method3")]
        url = self.test_graph.generate_graph(test_data, "TestValidGraph")
        request = requests.get(url)
        self.assertTrue(request.status_code == 200)

    def test_invalid_name_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md, [],
                          "test", "test", [])

    def test_invalid_desc_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md,
                          "TestInvalidReadme", [], "test", [])

    def test_invalid_licen_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md,
                          "TestInvalidReadme", "test", [], [])

    def test_invalid_req_readme(self):
        self.assertRaises(TypeError, self.test_readme.generate_readme_md,
                          "TestInvalidReadme", "test", "test", "test")

    def test_invalid_url_readme(self):
        self.assertRaises(ValueError, self.test_readme.generate_readme_md,
                          "TestInvalidReadme", "test", "test", [])

    def test_valid_readme(self):
        file_name = "TestValidGraph"
        test_data = [("class A", "class A", "method1"),
                     ("class B", "class A", "method2"),
                     ("class C", "class A", "method3")]
        self.test_readme.generate_graph(test_data, "TestValidGraph")
        self.test_readme.generate_readme_md("TestValidGraph", "test", "test",
                                            [])
        self.assertTrue(
            os.path.isfile(os.path.join(self.parsing_dir, file_name) + ".md"))

    def test_invalid_api(self):
        self.assertRaises(TypeError, self.test_api.generate_api, [])

    def test_valid_api(self):
        self.test_api.generate_api({})
        self.assertTrue(True)

    def test_valid_document(self):
        re = self.p.parse_project(self.git_address)
        #generate_document(self, data, name, raw_api, desc, licen, req):
        #tu = [graph, name, self.parse_api(), self.req_list, self.license]
        self.test_document.generate_document(re[0], re[1], re[2], "desc",
                                             re[4], re[3])
        self.assertTrue(
            os.path.isfile(
                os.path.join(self.parsing_dir, self.project_name) + ".md"))