Skip to content

Conversation

@ilu2112
Copy link
Contributor

@ilu2112 ilu2112 commented Jun 28, 2016

@opalczynski Here we go with PR. Please check if it's fine. If yes then I will adapt other models using the same approach.

… Meta class, apply changes to ScriptEndpoint model
raise SyncanoValidationError('Method allowed only on existing model.')

properties = self.get_endpoint_data()
endpoint = self._meta.resolve_endpoint('run', properties)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In:

    def resolve_endpoint(self, name, properties):
        endpoint = self.get_endpoint(name)

        for name in endpoint['properties']:
            if name not in properties:
                raise SyncanoValueError('Request property "{0}" is required.'.format(name))

        return endpoint['path'].format(**properties)

is get_endpoint which is:

    def get_endpoint(self, name):
        if name not in self.endpoints:
            raise SyncanoValueError('Invalid path name: "{0}".'.format(name))
        return self.endpoints[name]

Maybe we should add check in resolve_endpoint for that? Would be much cleaner. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@opalczynski Fine :)

@ilu2112
Copy link
Contributor Author

ilu2112 commented Jun 28, 2016

@opalczynski Please check this now :)


return endpoint['path'].format(**properties)

def is_http_method_available_for_endpoint(self, http_method_name, endpoint_name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_http_method_available_for_endpoint -> is_http_method_available is sufficient

@opalczynski
Copy link
Contributor

Please add some tests;

@ilu2112
Copy link
Contributor Author

ilu2112 commented Jun 28, 2016

Yes, tests will be there. I wanted to know if the approach is correct.

@ilu2112 ilu2112 changed the title [LIB-783] - Work in progress [LIB-783] - Correct endpoints check methods Jun 29, 2016
@ilu2112
Copy link
Contributor Author

ilu2112 commented Jun 29, 2016

@opalczynski it's ready :)

def poll(self, room=None, last_id=None, callback=None, error=None, timeout=None):
properties = self.get_endpoint_data()
endpoint = self._meta.resolve_endpoint('poll', properties)
endpoint = self._meta.resolve_endpoint('poll', properties, 'GET')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P you're using in all previous one the pattern:
http_method = 'GET'

self._meta.resolve(..., http_method)

maybe just add:
endpoint = self._meta.resolve_endpoint('poll', properties, http_method='GET')

or make http_method='GET' as default

@opalczynski
Copy link
Contributor

This is nice. One small comment. LGTM.

@opalczynski
Copy link
Contributor

++
just wait for the green CI :)

@ilu2112 ilu2112 merged commit 114d1e8 into develop Jul 4, 2016
@ilu2112 ilu2112 deleted the LIB-783 branch July 6, 2016 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants