The week that has been @ 2048

vipulgupta2048
Published: 07/16/2019


 

Week #8 10/07 to 16/07


 

I just realised that there aren’t many weeks left. Good times like these should never end. 


 

What did you do this week?

Good news, my PR for the validator has finally been merged. I am proud of it, great things coming forward → https://github.com/vipulgupta2048/spidermon/pull/2


 

Worked on finishing up the Translator as well, we had a change in direction in how we are going ahead on writing the tests for that class. I feel with the guidance of Julio especially on figuring out how to think about writing better tests really helped me out. Also, something extremely useful that I realized with using TDD in my thinking and coding is that while testing only, I find several edge cases that I never would have thought about. Check this out.


 

*After testing*

> r"^required field$":messages.MISSING_REQUIRED_FIELD,

This message allows only "required field" string to be passed. Which is what is needed, and works great. Here's the catch


 

*Earlier before testing I had,*

> r"required field":messages.MISSING_REQUIRED_FIELD,

Which led to the passing of all these string as well.

-  "not found required field"

- "aa required field aa"

- "required field almost anything here" and they all were getting translated.


 

Without testing, this would have lead to all kinds of troubles and TypeErrors. I am thankful to say the least, that testing has now become an integral part of my development work. Hence, the quote 


 

Good things happen when we test.


- Vipul Gupta (2019-20) 


 

What is coming up next? 

Start with the refactoring of the itemvalidation pipelines. Since that’s a more important task in hand. And now is priority one for the Team Cerber


 

Here’s the big feature missing that I will also be tackling.

Schema = {'quotes': {'type': ['string', 'list'], 'schema': {'type': 'string'}}}

Data = {'quotes': [1, 'Heureka!']}




Error found while testing - 

TypeError: {'quotes': [{0: ['must be of string type']}]}






 

About this, this is _something special_ with Cerberus.

*Reference* - https://docs.python-cerberus.org/en/stable/validation-rules.html#type 

*Context* - To introduce some diversity into the tests, I added this type of schemas where you can have multiple parameters set to as `type` to your values, the `schema` key governs what actually would be the type of your internal schema.

*About the Error* - I actually added the comments there, because the error we are getting is actually a parsing problem with the `Validator.py` parent class.

Usually, the errors we get and we parse are in the form of {field_name:message}, but here we are getting {field_name: {Array_element: message}} which I think is causing a typeError and something previous developers didn't account for since they never saw it coming with Cerberus. Cerberus is pretty good at showing detailed errors, hence I mentioned something related to not adding all the messages into the translator. But, this is something good that we caught here, as it would have never fit our use case in the future... Well, at least that's what my theory is.


 

Did you get stuck anywhere?

Yep, and I have been communicating a lot more with my nimble questions. I feel quite better asking, answering and discussing problem. Glad to figure that one out from my 1st eval. Quite happy with the work that’s happening as well. 

 

DJDT

Versions

Time

Settings from gsoc.settings

Headers

Request

SQL queries from 1 connection

Static files (2312 found, 3 used)

Templates (11 rendered)

Cache calls from 1 backend

Signals

Log messages