Exemplo n.º 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
     }])
Exemplo n.º 2
0
 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}
     ])
Exemplo n.º 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"), [])
Exemplo n.º 4
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"), [])
Exemplo n.º 5
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"), [])
Exemplo n.º 6
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")
Exemplo n.º 7
0
 def test_applications_fail_request(self, mock_urllib2):
     mock_urllib2.urlopen.side_effect = StandardError("Test")
     self.assertEqual(spark.applications("dummy"), None)
Exemplo n.º 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"), [])
Exemplo n.º 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")
Exemplo n.º 10
0
 def test_applications_fail_request(self, mock_urllib2):
     mock_urllib2.urlopen.side_effect = StandardError("Test")
     self.assertEqual(spark.applications("dummy"), None)