Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test functions in lexemes.py #25

Open
maany opened this issue Mar 12, 2019 · 4 comments
Open

test functions in lexemes.py #25

maany opened this issue Mar 12, 2019 · 4 comments
Labels

Comments

@maany
Copy link
Member

maany commented Mar 12, 2019

No description provided.

@maany maany added good first issue Good for newcomers gsoc2019 labels Mar 12, 2019
@kevalnagda
Copy link

Could you please provide any description for the issue. Thanks!

@maany
Copy link
Member Author

maany commented Mar 19, 2019

Hey, take a look at Pg 12 and Pg 20 in the specification
https://docs.google.com/document/d/1yp_96UXcwNO49cktnHtT61iNmTO0RgrSQukuNYqACpM/

Take a look at:
https://github.com/WLCG-Lightweight-Sites/simple_grid_yaml_compiler/tree/master/compiler

It defines two functions

  • get_repo_list
  • parse_for_variable_hierarchies

get_repo_list parses the site_level_config_file line by line and extracts some_url from 'repository_url: some_url' wherever it appears.
We need to write a test to validate different scenarios (types of url's) that can be successfully extracted by this function. The tests reside in :https://github.com/WLCG-Lightweight-Sites/simple_grid_yaml_compiler/blob/master/tests/tests_lexemes.py
Feel free to delete the existing test case as it is outdated.
You'd have to install pytest etc. in your virtual environment and include them in the requirements.txt file when you make a PR.

The second function, parse_for_variable_hierarchies, process the from keyword (mentioned in the specification). It looks through the site_level_config_file recursively for instances where the from keyword appears. It generally appears in the following format

var2: &var2 value_2
var1: &var1
 __from__: *var2

Take a look at: https://github.com/WLCG-Lightweight-Sites/wlcg_lightweight_site_ce_cream/blob/master/default-data.yaml

The function should reduce the output to

var1: value2

We gotta write a unit test to check this functionality in the same test_lexemes.py file mentioned above. Let me know if more info is needed :) .

@maany
Copy link
Member Author

maany commented Mar 30, 2019 via email

@Boot-Error
Copy link

Thanks for the explanation, I had trouble figuring this out because I wasn't aware of the improbable edge case of of CommentedSeq that has the keyword to match in it.

The from keyword, by definition, has to be the only child of a
Dict/CommentedMap. That's because the assignment operation is one to one
mapping rather than a one to many mapping. Therefore, if a CommentedSeq
contains a from keyword, the case should either not be processed or it
should throw an exception. In the other case i.e. if the user specified a
from keyword in a CommentedSeq, the data = data[keyword] line will
throw an exception, except for the case that the from referred to a
variable that represented a number and the ConnectedSeq had an entry
corresponding to that index.

This surely confirms the test condition I assumed in #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants