Exemplo n.º 1
0
 def __init__(self, args):
     super().__init__()
     self.updated_since = args.updated_since
     self.dump_dir = DUMP_DIR if os.path.isdir(DUMP_DIR) else None
     self.loop_delay = int(args.loop_delay)
     self.db = args.db
     if args.command == 'github_crawler':
         if args.repository:
             self.repository_el_re = "%s/%s" % (
                 args.org.lstrip('^'),
                 args.repository.lstrip('^'),
             )
         else:
             self.repository_el_re = args.org.lstrip('^') + '/.*'
         self.prf = pullrequest.PRsFetcher(
             GithubGraphQLQuery(token_getter=args.token_getter),
             args.base_url,
             args.org,
             args.repository,
         )
     elif args.command == 'gerrit_crawler':
         self.repository_el_re = args.repository.lstrip('^')
         self.prf = review.ReviewesFetcher(
             args.base_url,
             args.repository,
             args.insecure,
             login=args.login,
             password=args.password,
         )
Exemplo n.º 2
0
 def __init__(self,
              args,
              elastic_conn='localhost:9200',
              elastic_timeout=10):
     super().__init__()
     self.updated_since = args.updated_since
     self.dump_dir = DUMP_DIR if os.path.isdir(DUMP_DIR) else None
     self.loop_delay = int(args.loop_delay)
     self.db = ELmonocleDB(elastic_conn=elastic_conn,
                           index=args.index,
                           timeout=elastic_timeout)
     if args.command == 'github_crawler':
         if args.repository:
             self.repository_el_re = "%s/%s" % (
                 args.org.lstrip('^'),
                 args.repository.lstrip('^'),
             )
         else:
             self.repository_el_re = args.org.lstrip('^') + '/.*'
         self.prf = pullrequest.PRsFetcher(GithubGraphQLQuery(args.token),
                                           args.base_url, args.org,
                                           args.repository)
     elif args.command == 'gerrit_crawler':
         self.repository_el_re = args.repository.lstrip('^')
         self.prf = review.ReviewesFetcher(args.base_url, args.repository)
Exemplo n.º 3
0
 def __init__(self, args) -> None:
     super().__init__()
     self.updated_since = args.updated_since
     self.dump_dir = DUMP_DIR if os.path.isdir(DUMP_DIR) else None
     self.loop_delay = int(args.loop_delay)
     self.db: db.ELmonocleDB = args.db
     self.prf: Union[pullrequest.PRsFetcher, review.ReviewesFetcher]
     if args.command == "github_crawler":
         if args.repository:
             self.repository_el_re = "%s/%s" % (
                 args.org.lstrip("^"),
                 args.repository.lstrip("^"),
             )
         else:
             self.repository_el_re = args.org.lstrip("^") + "/.*"
         self.prf = pullrequest.PRsFetcher(
             GithubGraphQLQuery(token_getter=args.token_getter),
             args.base_url,
             args.org,
             args.repository,
         )
     elif args.command == "gerrit_crawler":
         self.repository_el_re = args.repository.lstrip("^")
         self.prf = review.ReviewesFetcher(
             args.base_url,
             args.repository,
             args.insecure,
             login=args.login,
             password=args.password,
         )
Exemplo n.º 4
0
    def extract_and_compare(self, base_url, name):
        input_review, xtrd_ref = load_change(name)

        rf = review.ReviewesFetcher(base_url, None)
        xtrd = rf.extract_objects([input_review], None)

        ddiff = DeepDiff(xtrd_ref, xtrd, ignore_order=True)
        if ddiff:
            raise DiffException(ddiff)
Exemplo n.º 5
0
 def test_load_buggy(self):
     """
     Gerrit crawler extracts buggy reviews
     """
     rf = review.ReviewesFetcher("https://gerrit.org", None, False, [])
     datasets_dir = Path(DATASETS)
     for fn in datasets_dir.glob("gerrit_*.json"):
         dataset = load_dataset(fn)
         xtrd = rf.extract_objects([dataset], lambda x, y: None)
         self.assertNotEqual(xtrd, [])
Exemplo n.º 6
0
    def extract_and_compare(self, base_url, name):
        input_review, xtrd_ref = load_change(name)

        rf = review.ReviewesFetcher(base_url, None)
        xtrd: List[Union[Change, Event]] = rf.extract_objects([input_review], None)

        ddiff = DeepDiff(
            xtrd_ref,
            [change_or_event_to_dict(x) for x in xtrd],
            ignore_order=True,
        )
        if ddiff:
            raise DiffException(ddiff)
Exemplo n.º 7
0
 def __init__(self, args):
     self.updated_since = args.updated_since
     self.loop_delay = int(args.loop_delay)
     self.get_one = getattr(args, 'id', None)
     self.db = ELmonocleDB()
     if args.command == 'github_crawler':
         self.get_one_rep = getattr(args, 'repository', None)
         self.org = args.org
         self.repository_el_re = args.org.lstrip('^') + '.*'
         self.prf = pullrequest.PRsFetcher(
             GithubGraphQLQuery(args.token),
             args.host, args.org)
     elif args.command == 'gerrit_crawler':
         self.repository_el_re = args.repository.lstrip('^')
         self.prf = review.ReviewesFetcher(
             args.host, args.repository)