Beispiel #1
0
 def test_get_attr(self):
     with mock.patch.object(FormField, 'we') as mock_we:
         test_obj = mock.Mock()
         test_obj.test_attr = 'test_value'
         mock_we.__get__ = mock.Mock(return_value=test_obj)
         obj = FormField(self.test_name, selector=self.selector)
         self.assertEqual(obj.__getattr__('test_attr'), 'test_value')
Beispiel #2
0
 def test_call_with_value_and_invalid_value(self):
     callable_test_function = mock.Mock(return_value='return_value')
     obj = FormField(self.test_name,
                     selector=self.selector,
                     value=callable_test_function,
                     invalid_value=callable_test_function)
     obj.value()
     self.assertTrue(obj.value.called)
Beispiel #3
0
 def setUp(self):
     self.test_proxy = mock.MagicMock()
     self.test_proxy.is_web_element = True
     self.test_proxy.browser = 'some_browser'
     self.test_weight = 1
     self.obj = FieldsGroup(self.test_proxy, weight=self.test_weight)
     self.field_FormField = FormField('test_field',
                                      selector=dict(),
                                      value='test_value',
                                      weight=1)
     self.obj.test_form = self.field_FormField
     self.test_field_group = mock.Mock(spec=FieldsGroup)
     self.obj.test_field_group = self.test_field_group
Beispiel #4
0
 def test_add_field(self):
     test_field = FormField('name', selector=dict(), weight=0)
     self.obj.add_field('test_name', test_field)
     self.assertEqual(self.obj._FieldsGroup__fields[0].name,
                      test_field.name)
Beispiel #5
0
 def test_call(self):
     obj = FormField(self.test_name, selector=self.selector)
     obj(self.test_group)
     self.assertIsNone(obj.value)
     self.assertIsNone(obj.invalid_value)
Beispiel #6
0
 def test_selector(self):
     obj = FormField(self.test_name, selector=self.selector)
     self.assertEqual(obj.selector, self.selector)
Beispiel #7
0
 def test_weight_without_value(self):
     obj = FormField(self.test_name, selector=self.selector)
     self.assertIsNone(obj.weight)
Beispiel #8
0
 def test_weight(self):
     obj = FormField(self.test_name,
                     selector=self.selector,
                     weight=self.test_weight)
     self.assertEqual(obj.weight, self.test_weight)
Beispiel #9
0
 def test_group_without_group(self):
     obj = FormField(self.test_name, selector=self.selector)
     with self.assertRaises(RuntimeError):
         obj.group
Beispiel #10
0
 def test_group(self):
     obj = FormField(self.test_name,
                     selector=self.selector,
                     group=self.test_group)
     self.assertEqual(obj.group, self.test_group)
Beispiel #11
0
 def test_constructor_with_dict_selector(self):
     obj = FormField(self.test_name, selector=self.selector)
     self.assertEqual(obj.name, self.test_name)
     self.assertEqual(obj.selector, self.selector)
Beispiel #12
0
 def test_constructor(self):
     with self.assertRaises(ValueError):
         obj = FormField(self.test_name)