コード例 #1
0
 def test_parse_file(self):
     dir = os.path.dirname(os.path.realpath(__file__))
     path = '{0}/../static/olsr-2-links.json'.format(dir)
     p = BaseParser(path)
     self.assertIsInstance(p.original_data, dict)
     with self.assertRaises(NetParserJsonException):
         BaseParser('../wrong.json')
コード例 #2
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_parse_file(self):
     dir = os.path.dirname(os.path.realpath(__file__))
     path = '{0}/static/olsr-2-links.json'.format(dir)
     p = BaseParser(file=path)
     self.assertIsInstance(p.original_data, dict)
     with self.assertRaises(TopologyRetrievalError):
         BaseParser(file='../wrong.json')
コード例 #3
0
ファイル: test_base.py プロジェクト: marfgold1/netdiff
 def test_topology_retrieval_error_http_404(self):
     responses.add(responses.GET,
                   'http://404.com',
                   body='not found',
                   status=404)
     with self.assertRaises(TopologyRetrievalError):
         BaseParser(url='http://404.com')
コード例 #4
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_topology_retrieval_error_http(self):
     def request_callback(request):
         raise ConnectionError('test exception')
     responses.add_callback(responses.GET, 'http://connectionerror.com',
                            callback=request_callback)
     with self.assertRaises(TopologyRetrievalError):
         BaseParser(url='http://connectionerror.com')
コード例 #5
0
ファイル: test_base.py プロジェクト: marfgold1/netdiff
 def test_parse_http(self):
     responses.add(
         responses.GET,
         'http://localhost:9090',
         body=self._load_contents('tests/static/olsr-2-links.json'))
     p = BaseParser(url='http://localhost:9090')
     self.assertIsInstance(p.original_data, dict)
コード例 #6
0
 def test_parse_json_exception(self):
     with self.assertRaises(NetParserJsonException):
         BaseParser('wrong [] ; .')
コード例 #7
0
 def test_parse_dict(self):
     p = BaseParser({})
     self.assertIsInstance(p.original_data, dict)
コード例 #8
0
 def test_parse_json_string(self):
     p = BaseParser('{}')
     self.assertIsInstance(p.original_data, dict)
     p = BaseParser(u'{}')
     self.assertIsInstance(p.original_data, dict)
コード例 #9
0
 def test_parse_http(self):
     url = 'http://raw.githubusercontent.com/ninuxorg/netdiff/e7b677fca3f16a4365e1fd5a6a81e1039abedce5/tests/olsr1/2links.json'
     p = BaseParser(url)
     self.assertIsInstance(p.original_data, dict)
コード例 #10
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_parse_error(self):
     with self.assertRaises(ConversionException):
         BaseParser(data=8)
コード例 #11
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_topology_retrieval_error_file(self):
     with self.assertRaises(TopologyRetrievalError):
         BaseParser(file='./tests/static/wrong.json')
コード例 #12
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_telnet_retrieval(self, MockClass):
     with self.assertRaises(ConversionException):
         BaseParser(url='telnet://127.0.0.1')
コード例 #13
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_telnet_retrieval_error(self, MockClass):
     telnetlib.Telnet.side_effect = ValueError('testing exception')
     with self.assertRaises(TopologyRetrievalError):
         BaseParser(url='telnet://wrong.com')
コード例 #14
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_no_data_supplied(self):
     with self.assertRaises(ValueError):
         BaseParser()
コード例 #15
0
ファイル: test_base.py プロジェクト: ninuxorg/netdiff
 def test_json_not_implemented(self):
     p = BaseParser(data='{}')
     with self.assertRaises(NotImplementedError):
         p.json()
コード例 #16
0
 def test_parse_exception(self):
     with self.assertRaises(NetParserException):
         BaseParser(8)
コード例 #17
0
 def test_json_not_implemented(self):
     p = BaseParser('{}')
     with self.assertRaises(NotImplementedError):
         p.json()
コード例 #18
0
ファイル: test_base.py プロジェクト: unsuitable001/netdiff
 def test_parse_conversion_exception(self):
     with self.assertRaises(ConversionException):
         BaseParser(data='wrong [] ; .')