Ejemplo n.º 1
0
 def test_get_tmp_storage_class_attribute(self):
     """Mock dynamically loading a class defined by an attribute"""
     target = "SomeClass"
     m = ImportMixin()
     m.tmp_storage_class = "tmpClass"
     with mock.patch("import_export.admin.import_string") as mock_import_string:
         mock_import_string.return_value = target
         self.assertEqual(target, m.get_tmp_storage_class())
 def test_get_import_data_kwargs_with_form_kwarg(self):
     """
     Test that if a the method is called with a 'form' kwarg,
     then it is removed and the updated dict is returned
     """
     request = MagicMock(spec=HttpRequest)
     m = ImportMixin()
     kw = {"a": 1, "form": "some_form"}
     target = {"a": 1}
     self.assertEqual(target, m.get_import_data_kwargs(request, **kw))
Ejemplo n.º 3
0
 def test_get_import_data_kwargs_with_no_form_kwarg_returns_empty_dict(self):
     """
     Test that if a the method is called with no 'form' kwarg,
     then an empty dict is returned
     """
     request = MagicMock(spec=HttpRequest)
     m = ImportMixin()
     kw = {
         "a": 1,
     }
     target = {}
     self.assertEqual(target, m.get_import_data_kwargs(request, **kw))
 def test_get_skip_admin_log_attribute(self):
     m = ImportMixin()
     m.skip_admin_log = True
     self.assertTrue(m.get_skip_admin_log())