예제 #1
0
 def test_validate_proxy_creds(self):
     data = {
         "proxy_url": "http://whatever",
         "proxy_username": "******",
         "proxy_password": "******"
     }
     data.update(self.minimal_data)
     serializer = RemoteSerializer(data=data)
     serializer.is_valid(raise_exception=True)
예제 #2
0
 def test_validate_proxy_creds_update(self):
     Remote = SimpleNamespace(
         proxy_url="http://whatever",
         proxy_username="******",
         proxy_password="******",
         **self.minimal_data,
     )
     data = {"proxy_username": "******"}
     serializer = RemoteSerializer(Remote, data=data, partial=True)
     serializer.is_valid(raise_exception=True)
예제 #3
0
 def test_validate_proxy_creds_update_invalid(self):
     Remote = SimpleNamespace(
         proxy_url="http://whatever",
         proxy_username=None,
         proxy_password=None,
         **self.minimal_data,
     )
     data = {"proxy_username": "******"}
     serializer = RemoteSerializer(Remote, data=data, partial=True)
     with self.assertRaises(serializers.ValidationError) as ctx:
         serializer.is_valid(raise_exception=True)
     self.assertIn("can only be specified together", str(ctx.exception))
예제 #4
0
 def test_validate_proxy_creds_invalid(self):
     data = {"proxy_url": "http://whatever", "proxy_username": "******"}
     data.update(self.minimal_data)
     serializer = RemoteSerializer(data=data)
     with self.assertRaises(serializers.ValidationError):
         serializer.is_valid(raise_exception=True)
예제 #5
0
 def test_validate_proxy(self):
     data = {"proxy_url": "http://whatever"}
     data.update(self.minimal_data)
     serializer = RemoteSerializer(data=data)
     serializer.is_valid(raise_exception=True)
예제 #6
0
 def test_minimal_data(self):
     data = {}
     data.update(self.minimal_data)
     serializer = RemoteSerializer(data=data)
     serializer.is_valid(raise_exception=True)