Giter Site home page Giter Site logo

django-inet's People

Contributors

grizz avatar lgtm-com[bot] avatar roysc avatar steffann avatar vegu avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-inet's Issues

drf 3.9.4 breaks tests on py27 / django 1.11

Easiest fix will be to drop py27 support soon. :)

______________________________ RestTestCase.test_validation ______________________________

self = <test_rest.RestTestCase testMethod=test_validation>

    def test_validation(self):
    
        # test valid addresses and prefixes (no errors expected)
        slz = InetSerializer(data={
            'ip' : '192.168.1.1',
            'ip4' : '192.168.1.1',
            'ip6' : 'fe80::1',
            'prefix' : '192.168.0.0/23',
            'prefix4' : '192.168.0.0/23',
            'prefix6' : '2001:0db8:35a3:0000::/64'
        })
        if not slz.is_valid():
            print(slz.errors)
        assert slz.is_valid()
    
        # test invalid addresses and prefixes (errors expected)
        data={
            'ip': 'invalid',
            'ip4': 'fe80::1',
            'ip6': '10.0.0.0',
            'prefix': 'invalid',
            'prefix4': 'fe80::/10',
            'prefix6': '192.168.0.0/23',
        }
        slz = InetSerializer(data=data)
>       assert not slz.is_valid()

tests/test_rest.py:45: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py27-django111/lib/python2.7/site-packages/rest_framework/serializers.py:236: in is_valid
    self._validated_data = self.run_validation(self.initial_data)
.tox/py27-django111/lib/python2.7/site-packages/rest_framework/serializers.py:434: in run_validation
    value = self.to_internal_value(data)
.tox/py27-django111/lib/python2.7/site-packages/rest_framework/serializers.py:491: in to_internal_value
    validated_value = field.run_validation(primitive_value)
.tox/py27-django111/lib/python2.7/site-packages/rest_framework/fields.py:793: in run_validation
    return super(CharField, self).run_validation(data)
.tox/py27-django111/lib/python2.7/site-packages/rest_framework/fields.py:536: in run_validation
    self.run_validators(value)
.tox/py27-django111/lib/python2.7/site-packages/rest_framework/fields.py:559: in run_validators
    errors.extend(get_error_detail(exc))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

exc_info = ValidationError([u"u'invalid' does not appear to be an IPv4 or IPv6 address"])

    def get_error_detail(exc_info):
        """
        Given a Django ValidationError, return a list of ErrorDetail,
        with the `code` populated.
        """
        code = getattr(exc_info, 'code', None) or 'invalid'
    
        try:
            error_dict = exc_info.error_dict
        except AttributeError:
            return [
                ErrorDetail(error.message % (error.params or ()),
                            code=error.code if error.code else code)
>               for error in exc_info.error_list]
E           TypeError: unsupported operand type(s) for %: 'exceptions.ValueError' and 'tuple'

.tox/py27-django111/lib/python2.7/site-packages/rest_framework/fields.py:244: TypeError

---------- coverage: platform linux2, python 2.7.5-final-0 -----------
Name                                                                      Stmts   Miss  Cover   Missing
-------------------------------------------------------------------------------------------------------
.tox/py27-django111/lib/python2.7/site-packages/django_inet/__init__.py       1      0   100%
.tox/py27-django111/lib/python2.7/site-packages/django_inet/models.py       132     21    84%   22, 42, 54, 139, 142-144, 147-149, 153, 159-160, 180, 184, 190-193, 196, 215
.tox/py27-django111/lib/python2.7/site-packages/django_inet/rest.py          15      0   100%
-------------------------------------------------------------------------------------------------------
TOTAL                                                                       148     21    86%

==================================== warnings summary ====================================
tests/models.py:13
  /home/grizz/c/gh/20c/django-inet/tests/models.py:13: DeprecationWarning: URLField has been deprecated and will be removed in version 1
    url = URLField(null=True, blank=True)

tests/test_models.py::ModelTests::test_init
  /home/grizz/c/gh/20c/django-inet/tests/test_models.py:33: DeprecationWarning: URLField has been deprecated and will be removed in version 1
    new0 = URLField()
  /home/grizz/c/gh/20c/django-inet/tests/test_models.py:34: DeprecationWarning: URLField has been deprecated and will be removed in version 1
    new1 = URLField()

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 1 failed, 12 passed, 3 warnings in 1.77 seconds =====================

Implement AddressSpaceValidator

Should raise validation error if entered ipaddress is in an unallowed space

Should support checking for:

is_multicast
is_private
is_unspecified
is_reserved
is_loopback
is_link_local

ASNField forever wants to add migrations

running manage.py makemigrations will always pick up a change on ASNField fields even though nothing has changed, making the migration and applying it doesnt fix the issue.

ASNField is too small

ASNField is a PositiveIntegerField, which means its range is from 0 to 2147483647 (2^31-1) because it is still stored as a signed integer in the database. An ASN is a unsigned 32-bit integer these days, and therefore has a range of 0 to 4294967295 (2^32-1). To be able to store all valid ASNs a PositiveBigIntegerField should be used.

BigPositiveIntegerField change only supported by 3.1

The fix pushed to address #10 introduced a change to PositiveBigIntegerField for ASNField - however this appears to be only supported by django 3.1 and forward.

We may need to look into a custom field implementation instead.

Django 2.0 support

IPAddressField calls _get_val_from_obj - this has been removed in django 2.0 and should be value_from_object

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.