def testunit_read_vsys_data_WHEN_missing_data_RETURNS_empty_result( self, mock_read_vsys_data_direct): mock_read_vsys_data_direct.return_value = {'version': 1} returned_value = mlab.read_vsys_data('fake_script', 1) self.assertDictEqual(returned_value, {})
def testunit_read_vsys_data_WHEN_wrong_version_RETURNS_data_anyway( self, mock_read_vsys_data_direct): mock_read_vsys_data_direct.return_value = {'data': 'x', 'version': 1} returned_value = mlab.read_vsys_data('fake_script', 2) self.assertEqual(returned_value, 'x')
def testunit_read_vsys_data_WHEN_missing_version_RETURNS_empty_result( self, mock_read_vsys_data_direct): mock_read_vsys_data_direct.return_value = {'data': {'rss': 2957312}} returned_value = mlab.read_vsys_data('fake_script', 2) self.assertDictEqual(returned_value, {})
def testunit_read_vsys_data_WHEN_wrong_message_type_RETURNS_empty_result( self, mock_read_vsys_data_direct): mock_read_vsys_data_direct.return_value = { 'data': 'x', 'version': 2, 'message_type': 'not_fake_script'} returned_value = mlab.read_vsys_data('fake_script', 2) self.assertDictEqual(returned_value, {})
def testunit_read_vsys_data_WHEN_wrong_message_type_RETURNS_empty_result( self, mock_read_vsys_data_direct): mock_read_vsys_data_direct.return_value = { 'data': 'x', 'version': 2, 'message_type': 'not_fake_script' } returned_value = mlab.read_vsys_data('fake_script', 2) self.assertDictEqual(returned_value, {})
def testunit_read_vsys_data_RETURNS_successfully(self): mock_vs = mock.Mock() mock_vs.sendrecv.return_value = ( '{"version": %d, "message_type": "fake_request", ' '"data": {"rss": 3000000}}') % mlab._VSYS_FRONTEND_VERSION mlab._vs_vsys = mock_vs expected_response = {'rss': 3000000} returned_value = mlab.read_vsys_data('fake_request', mlab._VSYS_FRONTEND_VERSION) self.assertDictEqual(returned_value, expected_response)
def testunit_read_vsys_data_RETURNS_successfully(self): mock_vs = mock.Mock() mock_vs.sendrecv.return_value = ( '{"version": %d, "message_type": "fake_request", ' '"data": {"rss": 3000000}}') % mlab._VSYS_FRONTEND_VERSION mlab._vs_vsys = mock_vs expected_response = {'rss': 3000000} returned_value = mlab.read_vsys_data( 'fake_request', mlab._VSYS_FRONTEND_VERSION) self.assertDictEqual(returned_value, expected_response)