jdiegodcp / ramlfications

Python parser for RAML
https://ramlfications.readthedocs.org
Apache License 2.0
234 stars 50 forks source link

Raml parser: support parsing fragments as the root node #83

Closed tardyp closed 8 years ago

tardyp commented 8 years ago

Trying to spilt my big PR into smaller PR in the hope I can get something merged Actually, this led to a much bigger PR, but dont worry, it is mostly a find replace renaming of RootNode...

For now, only datatype is introduced (actual implementation will be in the data type PR)

raml1.0 introduces possibility to split your REST api def into several parts

Interresting side effect of this is that you can use raml as a data-validator library.

a raml datatype file can be used for the same means as: json schema http://cerberus.readthedocs.org https://pypi.python.org/pypi/yamltypes

codecov-io commented 8 years ago

Current coverage is 97.07%

Branch #83 has no coverage reports uploaded yet.

Powered by Codecov. Updated on successful CI builds.

econchick commented 8 years ago

Hmm I'm not sure how this passed - when I check it out locally I get a syntax error:

ramlfications git:(916e523) py.test tests/test_parser.py
====================================================================================== test session starts ======================================================================================
platform darwin -- Python 2.7.9, pytest-2.8.2, py-1.4.31, pluggy-0.3.1
rootdir: /Users/lynn/Dev/spotify/ramlfications, inifile:
plugins: cov-2.2.0, localserver-0.3.4, mock-0.4.3
collected 0 items / 1 errors

============================================================================================ ERRORS =============================================================================================
_____________________________________________________________________________ ERROR collecting tests/test_parser.py _____________________________________________________________________________
../../../.pyenv/versions/raml-27/lib/python2.7/site-packages/_pytest/python.py:591: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
../../../.pyenv/versions/raml-27/lib/python2.7/site-packages/py/_path/local.py:650: in pyimport
    __import__(modname)
../../../.pyenv/versions/raml-27/lib/python2.7/site-packages/_pytest/assertion/rewrite.py:171: in load_module
    py.builtin.exec_(co, mod.__dict__)
tests/test_parser.py:10: in <module>
    from ramlfications import parser as pw
ramlfications/__init__.py:7: in <module>
    from ramlfications.parser import parse_raml
ramlfications/parser/__init__.py:12: in <module>
    from .main import (
ramlfications/parser/main.py:15: in <module>
    from ramlfications.raml import (
ramlfications/raml.py:93: in <module>
    class RootNodeAPI08(RootNodeAPIBase):
../../../.pyenv/versions/raml-27/lib/python2.7/site-packages/attr/_make.py:194: in attributes
    return wrap(maybe_cl)
../../../.pyenv/versions/raml-27/lib/python2.7/site-packages/attr/_make.py:186: in wrap
    cl = _add_init(cl)
../../../.pyenv/versions/raml-27/lib/python2.7/site-packages/attr/_make.py:340: in _add_init
    bytecode = compile(script, unique_filename, "exec")
E   SyntaxError: duplicate argument 'raw' in function definition (<attrs generated init c1f77a313351c8b26088d0619b6349e525c10434>, line 1)

The PR otherwise makes sense to me.

tardyp commented 8 years ago

I think this is because you have an old pyc of a unit test added by #80 The code is actually untested in #83, and I fixed the issue in #80

tardyp commented 8 years ago

after double check, I can see all tests pass on that branch, and on the same commit as you tested :-/


(ramlfications/sandbox)  ~/dev/bb/ramlfications git:(ramlfragments)
0 % git lol |head
* 916e523 (HEAD, origin/ramlfragments, ramlfragments) Raml parser: support parsing fragments as the root node
* 86e3dc1 (spotify/v0.2.0-dev) remove unneeded commented-out code
* c595839 remove random notes file that was not meant to be commited
* 3e3b7db uncommented out forgotten but working tests
*   ab37dab Merge pull request #82 from spotify/lynn/fix-uri-params
|\
| * d3a58a7 (spotify/lynn/fix-uri-params) fixed order of uri/base uri params; create undeclared uri params
|/
* e319dec add travis config
* 9f73631 forgot to commit a test raml
(ramlfications/sandbox)  ~/dev/bb/ramlfications git:(ramlfragments)
0 % py.test --looponfail tests --ignore tests/integration
============================= test session starts ==============================
platform darwin -- Python 2.7.10 -- py-1.4.31 -- pytest-2.6.4
plugins: cov, localserver, mock, xdist, xdist, xdist
collected 225 items
collected 225 items

tests/test_config.py ...
tests/test_helpers.py ...
tests/test_init.py .......
tests/test_loader.py ...........................
tests/test_main.py .....
tests/test_parameter_tags.py ..
tests/test_parameters.py .
tests/test_parser.py .........................................................................
tests/test_tree.py ...sss
tests/test_utils.py ............
tests/test_validate.py ...................................
tests/raml10tests/test_basic.py .
tests/v020tests/test_inherited_resource_types.py ..
tests/v020tests/test_inherited_traits.py ..
tests/v020tests/test_resource_types.py ..............
tests/v020tests/test_resources.py .................
tests/v020tests/test_root_node.py .
tests/v020tests/test_security_schemes.py ......
tests/v020tests/test_traits.py ........

==================== 222 passed, 3 skipped in 8.87 seconds =====================
econchick commented 8 years ago

@tardyp wat?! so weird! I did a fresh clone, fetched your particular PR branch (commit # 916e5230abaa1cac34b374aa4a034b78802e1e89) and ran py.test tests/test_parser.py and I'm still getting the same issues.

econchick commented 8 years ago

ahhh nevermind @tardyp ! I figured it out - I had an old attrs in my virtualenv. This is because I'm on my travel computer, not my work computer. phew okay glad that problem is solved!