コード例 #1
0
 def test_applications_no_running(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.return_value = [{
         "id":
         "1",
         "name":
         "abc",
         "attempts": [{
             "completed": True
         }, {
             "completed": True
         }]
     }, {
         "id": "2",
         "name": "abc",
         "attempts": [{
             "completed": True
         }]
     }]
     self.assertEqual(spark.applications("url"), [{
         "id": "1",
         "name": "abc",
         "completed": True
     }, {
         "id": "2",
         "name": "abc",
         "completed": True
     }])
コード例 #2
0
ファイル: test_spark.py プロジェクト: sadikovi/queue
 def test_applications_running(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.return_value = [
         {"id": "1", "name": "abc", "attempts": [{"completed": True}, {"completed": False}]},
         {"id": "2", "name": "abc", "attempts": [{"completed": True}]}
     ]
     self.assertEqual(spark.applications("url"), [
         {"id": "1", "name": "abc", "completed": False},
         {"id": "2", "name": "abc", "completed": True}
     ])
コード例 #3
0
 def test_applications_invalid_data(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.return_value = [{
         "a": "2",
         "b": "abc",
         "c": [{
             "completed": True
         }]
     }]
     self.assertEqual(spark.applications("url"), [])
コード例 #4
0
ファイル: test_spark.py プロジェクト: sadikovi/queue
 def test_applications_invalid_data(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.return_value = [
         {"a": "2", "b": "abc", "c": [{"completed": True}]}
     ]
     self.assertEqual(spark.applications("url"), [])
コード例 #5
0
ファイル: test_spark.py プロジェクト: sadikovi/queue
 def test_applications_no_data(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.return_value = []
     self.assertEqual(spark.applications("url"), [])
コード例 #6
0
ファイル: test_spark.py プロジェクト: sadikovi/queue
 def test_applications_fail_json(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.side_effect = ValueError("Test")
     with self.assertRaises(ValueError):
         spark.applications("url")
コード例 #7
0
ファイル: test_spark.py プロジェクト: sadikovi/queue
 def test_applications_fail_request(self, mock_urllib2):
     mock_urllib2.urlopen.side_effect = StandardError("Test")
     self.assertEqual(spark.applications("dummy"), None)
コード例 #8
0
 def test_applications_no_data(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.return_value = []
     self.assertEqual(spark.applications("url"), [])
コード例 #9
0
 def test_applications_fail_json(self, mock_json, mock_urllib2):
     mock_urllib2.urlopen.return_value = mock.Mock()
     mock_json.loads.side_effect = ValueError("Test")
     with self.assertRaises(ValueError):
         spark.applications("url")
コード例 #10
0
 def test_applications_fail_request(self, mock_urllib2):
     mock_urllib2.urlopen.side_effect = StandardError("Test")
     self.assertEqual(spark.applications("dummy"), None)