Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertIsInstance(parser, BackendCommandArgumentParser)
self.assertEqual(parser._backend, Groupsio)
args = ['acme_group',
'--mboxes-path', '/tmp/perceval/',
'--tag', 'test',
'--from-date', '1970-01-01',
'--no-verify',
'--email', 'jsmith@example.com',
'--password', 'aaaaa']
parsed_args = parser.parse(*args)
self.assertEqual(parsed_args.group_name, 'acme_group')
self.assertEqual(parsed_args.mboxes_path, '/tmp/perceval/')
self.assertEqual(parsed_args.tag, 'test')
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
self.assertFalse(parsed_args.verify)
self.assertEqual(parsed_args.email, 'jsmith@example.com')
self.assertEqual(parsed_args.password, 'aaaaa')
self.assertEqual(parsed_args.from_date, expected)
self.assertEqual(parsed_args.to_date, None)
# Invalid 'from-date'
args = ['--from-date', 'asdf']
with self.assertRaises(InvalidDateError):
parsed_args = parser.parse(*args)
# Check argument 'to-date'
args = ['--to-date', '2016-01-01']
parsed_args = parser.parse(*args)
expected_dt = datetime.datetime(2016, 1, 1, 0, 0,
tzinfo=dateutil.tz.tzutc())
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
self.assertEqual(parsed_args.to_date, expected_dt)
# Invalid 'to-date'
args = ['--to-date', 'asdf']
with self.assertRaises(InvalidDateError):
parsed_args = parser.parse(*args)
# Check both arguments
args = ['--from-date', '2015-01-01', '--to-date', '2016-01-01']
parsed_args = parser.parse(*args)
self.assertEqual(parsed_args.from_date, expected)
self.assertEqual(parsed_args.to_date, expected_dt)
"""Test if it parser object is correctly initialized"""
parser = HyperKittyCommand.setup_cmd_parser()
self.assertIsInstance(parser, BackendCommandArgumentParser)
self.assertEqual(parser._backend, HyperKitty)
args = ['http://example.com/archives/list/test@example.com/',
'--mboxes-path', '/tmp/perceval/',
'--tag', 'test',
'--from-date', '1970-01-01']
parsed_args = parser.parse(*args)
self.assertEqual(parsed_args.url, 'http://example.com/archives/list/test@example.com/')
self.assertEqual(parsed_args.mboxes_path, '/tmp/perceval/')
self.assertEqual(parsed_args.tag, 'test')
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
parser = PipermailCommand.setup_cmd_parser()
self.assertIsInstance(parser, BackendCommandArgumentParser)
self.assertEqual(parser._backend, Pipermail)
args = ['http://example.com/',
'--mboxes-path', '/tmp/perceval/',
'--tag', 'test',
'--from-date', '1970-01-01',
'--no-verify']
parsed_args = parser.parse(*args)
self.assertEqual(parsed_args.url, 'http://example.com/')
self.assertEqual(parsed_args.mboxes_path, '/tmp/perceval/')
self.assertEqual(parsed_args.tag, 'test')
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
self.assertFalse(parsed_args.verify)
self.assertEqual(parsed_args.git_path, '/tmp/gitpath')
self.assertEqual(parsed_args.tag, 'test')
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
args = ['http://example.com/',
'--git-path', '/tmp/gitpath',
'--tag', 'test',
'--exec-path', JADOLINT_PATH,
'--category', CATEGORY_COQUA_JADOLINT,
'--in-paths', 'Dockerfile', 'Dockerfile-full', 'Dockerfile-secured']
parsed_args = parser.parse(*args)
self.assertEqual(parsed_args.uri, 'http://example.com/')
self.assertEqual(parsed_args.git_path, '/tmp/gitpath')
self.assertEqual(parsed_args.tag, 'test')
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
self.assertEqual(parsed_args.category, CATEGORY_COQUA_JADOLINT),
self.assertEqual(parsed_args.exec_path, JADOLINT_PATH)
self.assertListEqual(parsed_args.in_paths, ['Dockerfile', 'Dockerfile-full', 'Dockerfile-secured'])
'--max-items', '5',
'--tag', 'test',
'--no-archive',
'--from-date', '1970-01-01',
'--sleep-for-rate',
'--min-rate-to-sleep', '10',
'--sleep-time', '10']
parsed_args = parser.parse(*args)
self.assertEqual(parsed_args.url, 'https://mattermost.example.com/')
self.assertEqual(parsed_args.channel, 'abcdefghijkl')
self.assertEqual(parsed_args.api_token, 'aaaa')
self.assertEqual(parsed_args.max_items, 5)
self.assertEqual(parsed_args.tag, 'test')
self.assertEqual(parsed_args.no_archive, True)
self.assertEqual(parsed_args.from_date, DEFAULT_DATETIME)
self.assertEqual(parsed_args.sleep_for_rate, True)
self.assertEqual(parsed_args.min_rate_to_sleep, 10)
self.assertEqual(parsed_args.sleep_time, 10)
def fetch(self, category=CATEGORY_COVULN, paths=None,
from_date=DEFAULT_DATETIME, to_date=DEFAULT_LAST_DATETIME,
branches=None, latest_items=False):
"""Fetch commits and add code vulnerabilities information."""
items = super().fetch(category,
from_date=from_date, to_date=to_date,
branches=branches, latest_items=latest_items)
return items
def fetch(self, category=CATEGORY_REVIEW, from_date=DEFAULT_DATETIME):
"""Fetch the reviews from the repository.
The method retrieves, from a Gerrit repository, the reviews
updated since the given date.
:param category: the category of items to fetch
:param from_date: obtain reviews updated since this date
:returns: a generator of reviews
"""
if not from_date:
from_date = DEFAULT_DATETIME
kwargs = {'from_date': from_date}
items = super().fetch(category, **kwargs)
elif len(branches) == 0:
branches_text = "no"
else:
branches_text = ", ".join(branches)
logger.info("Fetching commits: '%s' git repository from %s to %s; %s branches",
self.uri, str(from_date), str(to_date), branches_text)
# Ignore default datetime to avoid problems with git
# or convert to UTC
if to_date == DEFAULT_LAST_DATETIME:
to_date = None
else:
to_date = datetime_to_utc(to_date)
if from_date == DEFAULT_DATETIME:
from_date = None
else:
from_date = datetime_to_utc(from_date)
if not no_update:
repo.update()
gitlog = repo.log(from_date, to_date, branches)
return self.parse_git_log_from_iter(gitlog)
def fetch(self, category=CATEGORY_EVENT, from_date=DEFAULT_DATETIME, to_date=None,
filter_classified=False):
"""Fetch the events from the server.
This method fetches those events of a group stored on the server
that were updated since the given date. Data comments and rsvps
are included within each event.
:param category: the category of items to fetch
:param from_date: obtain events updated since this date
:param to_date: obtain events updated before this date
:param filter_classified: remove classified fields from the resulting items
:returns: a generator of events
"""
if not from_date:
from_date = DEFAULT_DATETIME