def _atest_list_execute(self, filters={}, check_results={}):
     values = [{u'id': 180,
                u'platform': 0,
                u'name': u'label0',
                u'invalid': 0,
                u'kernel_config': u''},
               {u'id': 338,
                u'platform': 0,
                u'name': u'label1',
                u'invalid': 0,
                u'kernel_config': u''}]
     mytest = action_common.atest_list()
     mytest.afe = rpc.afe_comm()
     self.mock_rpcs([('get_labels',
                      filters,
                      True,
                      values)])
     self.god.mock_io()
     self.assertEqual(values,
                      mytest.execute(op='get_labels',
                                     filters=filters,
                                     check_results=check_results))
     (out, err) = self.god.unmock_io()
     self.god.check_playback()
     return (out, err)
 def test_atest_list_execute_filters_wildcard(self):
     filters = {}
     check_results = {}
     filters['name__in'] = ['label*']
     check_results['name__in'] = 'name'
     values = [{u'id': 180,
                u'platform': False,
                u'name': u'label0',
                u'invalid': False,
                u'kernel_config': u''},
               {u'id': 338,
                u'platform': False,
                u'name': u'label1',
                u'invalid': False,
                u'kernel_config': u''}]
     mytest = action_common.atest_list()
     mytest.afe = rpc.afe_comm()
     self.mock_rpcs([('get_labels', {'name__startswith': 'label'},
                      True, values)])
     self.god.mock_io()
     self.assertEqual(values,
                      mytest.execute(op='get_labels',
                                     filters=filters,
                                     check_results=check_results))
     (out, err) = self.god.unmock_io()
     self.god.check_playback()
     self.assertEqual(err, '')
Beispiel #3
0
 def _atest_list_execute(self, filters={}, check_results={}):
     values = [{
         u'id': 180,
         u'platform': 0,
         u'name': u'label0',
         u'invalid': 0,
         u'kernel_config': u''
     }, {
         u'id': 338,
         u'platform': 0,
         u'name': u'label1',
         u'invalid': 0,
         u'kernel_config': u''
     }]
     mytest = action_common.atest_list()
     mytest.afe = rpc.afe_comm()
     self.mock_rpcs([('get_labels', filters, True, values)])
     self.god.mock_io()
     self.assertEqual(
         values,
         mytest.execute(op='get_labels',
                        filters=filters,
                        check_results=check_results))
     (out, err) = self.god.unmock_io()
     self.god.check_playback()
     return (out, err)
Beispiel #4
0
 def test_atest_list_execute_filters_wildcard(self):
     filters = {}
     check_results = {}
     filters['name__in'] = ['label*']
     check_results['name__in'] = 'name'
     values = [{
         u'id': 180,
         u'platform': False,
         u'name': u'label0',
         u'invalid': False,
         u'kernel_config': u''
     }, {
         u'id': 338,
         u'platform': False,
         u'name': u'label1',
         u'invalid': False,
         u'kernel_config': u''
     }]
     mytest = action_common.atest_list()
     mytest.afe = rpc.afe_comm()
     self.mock_rpcs([('get_labels', {
         'name__startswith': 'label'
     }, True, values)])
     self.god.mock_io()
     self.assertEqual(
         values,
         mytest.execute(op='get_labels',
                        filters=filters,
                        check_results=check_results))
     (out, err) = self.god.unmock_io()
     self.god.check_playback()
     self.assertEqual(err, '')
    def test_check_for_wilcard_one_string_login(self):
        filters = {'something__login': '******'}
        checks = {'something__login': '******'}
        mytest = action_common.atest_list()

        mytest.check_for_wildcard(filters, checks)
        self.assertEqual(filters, {'something__login__startswith': 'item'})
        self.assertEqual(checks, {'something__login__startswith': None})
Beispiel #6
0
    def test_check_for_wilcard_one_string_login(self):
        filters = {'something__login': '******'}
        checks = {'something__login': '******'}
        mytest = action_common.atest_list()

        mytest.check_for_wildcard(filters, checks)
        self.assertEqual(filters, {'something__login__startswith': 'item'})
        self.assertEqual(checks, {'something__login__startswith': None})
    def test_check_for_wilcard_none_list(self):
        orig_filters = {'name__in': ['item0']}
        orig_checks = {'name__in': ['item0']}
        mytest = action_common.atest_list()

        filters = copy.deepcopy(orig_filters)
        checks = copy.deepcopy(orig_checks)
        mytest.check_for_wildcard(filters, checks)
        self.assertEqual(filters, orig_filters)
        self.assertEqual(checks, orig_checks)
Beispiel #8
0
    def test_check_for_wilcard_none_list(self):
        orig_filters = {'name__in': ['item0']}
        orig_checks = {'name__in': ['item0']}
        mytest = action_common.atest_list()

        filters = copy.deepcopy(orig_filters)
        checks = copy.deepcopy(orig_checks)
        mytest.check_for_wildcard(filters, checks)
        self.assertEqual(filters, orig_filters)
        self.assertEqual(checks, orig_checks)
    def test_check_for_wilcard_two(self):
        orig_filters = {'something__in': ['item0*', 'item1*']}
        orig_checks = {'something__in': ['item0*', 'item1*']}
        mytest = action_common.atest_list()

        filters = copy.deepcopy(orig_filters)
        checks = copy.deepcopy(orig_checks)
        self.god.stub_function(sys, 'exit')
        sys.exit.expect_call(1).and_raises(cli_mock.ExitException)
        self.god.mock_io()
        self.assertRaises(cli_mock.ExitException,
                          mytest.check_for_wildcard, filters, checks)
        (out, err) = self.god.unmock_io()
        self.god.check_playback()
        self.assertEqual(filters, orig_filters)
        self.assertEqual(checks, orig_checks)
Beispiel #10
0
    def test_check_for_wilcard_two(self):
        orig_filters = {'something__in': ['item0*', 'item1*']}
        orig_checks = {'something__in': ['item0*', 'item1*']}
        mytest = action_common.atest_list()

        filters = copy.deepcopy(orig_filters)
        checks = copy.deepcopy(orig_checks)
        self.god.stub_function(sys, 'exit')
        sys.exit.expect_call(1).and_raises(cli_mock.ExitException)
        self.god.mock_io()
        self.assertRaises(cli_mock.ExitException, mytest.check_for_wildcard,
                          filters, checks)
        (out, err) = self.god.unmock_io()
        self.god.check_playback()
        self.assertEqual(filters, orig_filters)
        self.assertEqual(checks, orig_checks)