コード例 #1
0
 def test_resolve_django_model(self):
     resolved_model = _resolve_model(BasicModel)
     self.assertEqual(resolved_model, BasicModel)
コード例 #2
0
 def test_resolve_string_representation(self):
     resolved_model = _resolve_model('tests.BasicModel')
     self.assertEqual(resolved_model, BasicModel)
コード例 #3
0
 def test_resolve_string_representation(self):
     resolved_model = _resolve_model('tests.BasicModel')
     assert resolved_model == BasicModel
コード例 #4
0
 def test_resolve_unicode_representation(self):
     resolved_model = _resolve_model(six.text_type('tests.BasicModel'))
     assert resolved_model == BasicModel
コード例 #5
0
 def test_resolve_django_model(self):
     resolved_model = _resolve_model(BasicModel)
     assert resolved_model == BasicModel
コード例 #6
0
 def test_resolve_django_model(self):
     resolved_model = _resolve_model(BasicModel)
     assert resolved_model == BasicModel
コード例 #7
0
 def test_resolve_non_django_model(self):
     with self.assertRaises(ValueError):
         _resolve_model(TestCase)
コード例 #8
0
 def test_resolve_improper_string_representation(self):
     with self.assertRaises(ValueError):
         _resolve_model('BasicModel')
コード例 #9
0
 def test_resolve_string_representation(self):
     resolved_model = _resolve_model('tests.BasicModel')
     self.assertEqual(resolved_model, BasicModel)
コード例 #10
0
 def test_resolve_unicode_representation(self):
     resolved_model = _resolve_model(six.text_type('tests.BasicModel'))
     self.assertEqual(resolved_model, BasicModel)
コード例 #11
0
 def test_resolve_django_model(self):
     resolved_model = _resolve_model(BasicModel)
     self.assertEqual(resolved_model, BasicModel)
コード例 #12
0
 def test_resolve_unicode_representation(self):
     resolved_model = _resolve_model(six.text_type('tests.BasicModel'))
     assert resolved_model == BasicModel
コード例 #13
0
 def test_resolve_string_representation(self):
     resolved_model = _resolve_model('tests.BasicModel')
     assert resolved_model == BasicModel
コード例 #14
0
 def test_resolve_unicode_representation(self):
     resolved_model = _resolve_model(six.text_type('tests.BasicModel'))
     self.assertEqual(resolved_model, BasicModel)
コード例 #15
0
 def test_resolve_improper_string_representation(self):
     with self.assertRaises(ValueError):
         _resolve_model('BasicModel')
コード例 #16
0
 def test_resolve_non_django_model(self):
     with self.assertRaises(ValueError):
         _resolve_model(TestCase)
コード例 #17
0
 def test_blows_up_if_model_does_not_resolve(self):
     with self.assertRaises(ImproperlyConfigured):
         _resolve_model('tests.BasicModel')
コード例 #18
0
 def test_blows_up_if_model_does_not_resolve(self):
     with self.assertRaises(ImproperlyConfigured):
         _resolve_model('tests.BasicModel')
コード例 #19
0
def get_related_model(field):
    # Backward compatibility patch for Django versions lower than 1.9.x
    # Function taken from DRF 3.6.x
    if DJANGO_VERSION < (1, 9):
        return _resolve_model(field.rel.to)
    return field.remote_field.model