Exemplo n.º 1
0
    def test_apply_api(self):
        args = default_args()
        api = ApiAction(args)
        c = Mock()
        c.import_rest_api = Mock(return_value='import_rest_api')
        c.put_rest_api = Mock(return_value='put_rest_api')
        c.get_rest_api = Mock(return_value=None)
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), 'import_rest_api')
        c.get_rest_api = Mock(return_value='baz')
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), 'put_rest_api')

        args = default_args()
        args.remove = True
        api = ApiAction(args)
        c.get_rest_api = Mock(return_value=None)
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), None)
        c.get_rest_api = Mock(return_value='baz')
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), None)
Exemplo n.º 2
0
    def test_apply_api(self):
        args = default_args()
        api = ApiAction(args)
        c = Mock()
        c.import_rest_api = Mock(return_value='import_rest_api')
        c.put_rest_api = Mock(return_value='put_rest_api')
        c.get_rest_api = Mock(return_value=None)
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), 'import_rest_api')
        c.get_rest_api = Mock(return_value='baz')
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), 'put_rest_api')

        args = default_args()
        args.remove = True
        api = ApiAction(args)
        c.get_rest_api = Mock(return_value=None)
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), None)
        c.get_rest_api = Mock(return_value='baz')
        eq_(api._apply_api(c, 'baz', {'foo': 'bar'}), None)
Exemplo n.º 3
0
 def test_action(self):
     args = default_args()
     api = ApiAction(args)
     api._config.save_api_id = Mock()
     api._get_client = Mock()
     api._apply_api = Mock(
         return_value={'id': 'foo', 'name': 'bar', 'description': 'baz'})
     api._deploy = Mock(
         return_value={'id': 'foo', 'apiSummary': 'bar', 'description': 'baz'})
     api._get_remote_configuration = Mock(return_value={})
     api.action()
Exemplo n.º 4
0
 def test_action(self):
     args = default_args()
     api = ApiAction(args)
     api._config.save_api_id = Mock()
     api._get_client = Mock()
     api._apply_api = Mock(return_value={
         'id': 'foo',
         'name': 'bar',
         'description': 'baz'
     })
     api._deploy = Mock(return_value={
         'id': 'foo',
         'apiSummary': 'bar',
         'description': 'baz'
     })
     api._get_remote_configuration = Mock(return_value={})
     api.action()