-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More work on #5 , introducing mutually exclusive arguments for argpas…
…e. Adding some test cases as well
- Loading branch information
pgaref
committed
Aug 1, 2017
1 parent
4f75687
commit 6f9e600
Showing
2 changed files
with
66 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
sys.path.insert(0, os.path.abspath('.')) | ||
from http_request_randomizer.requests.runners.proxyList import ProxyList, create_parser | ||
|
||
|
||
class ParserTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.proxyList = ProxyList() | ||
self.parser = create_parser(self.proxyList) | ||
|
||
def test_ParserSource(self): | ||
parsed = self.parser.parse_args(['-s', 'freeproxy']) | ||
self.assertEqual(parsed.sources, ['freeproxy']) | ||
|
||
parsed = self.parser.parse_args(['-s', 'freeproxy', 'all', 'proxyforeu']) | ||
self.assertEqual(parsed.sources, ['freeproxy', 'all', 'proxyforeu']) | ||
|
||
with self.assertRaises(SystemExit): | ||
self.parser.parse_args(['-s']) | ||
self.parser.parse_args(['-s', 'blah']) | ||
|
||
def test_ParserList(self): | ||
parsed = self.parser.parse_args(['-ls', 'providers']) | ||
self.assertEqual(parsed.list, ['providers']) | ||
|
||
parsed = self.parser.parse_args(['-ls', 'agents']) | ||
self.assertEqual(parsed.list, ['agents']) | ||
|
||
with self.assertRaises(SystemExit): | ||
self.parser.parse_args(['-ls']) | ||
self.parser.parse_args(['-ls', 'test']) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|