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

Migrated commit_represent to S3Represent #1182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anurag-ks
Copy link
Contributor

No description provided.

"""
table = current.s3db.req_commit
if row.type == 1:
return "%s - %s" % (table.site_id.represent(row.site_id),
Copy link
Member

Choose a reason for hiding this comment

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

Makes no difference with S3Represent if you call other represents per-row.

Copy link
Member

Choose a reason for hiding this comment

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

You should call the bulk-method of the same (!) represent instances once during lookup_rows for /all/ values.

That will store the representations in the instance, so that when you call them per-row in represent_row, they wouldn't be looked up again.

@anurag-ks
Copy link
Contributor Author

@nursix and @flavour done

"""

table = current.s3db.req_commit
super(req_CommitRepresent, self).__init__()
Copy link
Member

Choose a reason for hiding this comment

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

This constructor does basically nothing - so should be removed.

@nursix
Copy link
Member

nursix commented Oct 13, 2015

This is the right concept - but a sloppy implementation of it ;)

You should always test your code before submitting a PR - and this code can not work, so you either didn't test it, or you ignored that it doesn't work ;)

@anurag-ks
Copy link
Contributor Author

Actually @nursix I did tried to test it, but I think they way I tested it is wrong, sorry for that.

@nursix
Copy link
Member

nursix commented Oct 13, 2015

@anurag-ks - generally no problem to ask for feedback on the concept by tagging me in a comment to your commit before submitting a PR. But for a PR, stuff should be working.

You could try to write a unit test for this (even if just as an exercise) - this would give you immediate feedback while refactoring things.

@anurag-ks
Copy link
Contributor Author

@nursix just a doubt, these represent classes/functions are used for custom rendering of data values for data-tables or exporting data, right ? But on enabling the commit_id field on /eden/req/commit gives me None

@flavour
Copy link
Member

flavour commented Oct 13, 2015

for req/commit there is no 'commit_id' field, there is an 'id' field which in other places would be seen as a commit_id

@flavour
Copy link
Member

flavour commented Oct 13, 2015

these represent classes/functions are used for custom rendering of data values for data-tables or exporting data, right ?

yes

@anurag-ks
Copy link
Contributor Author

Okay so commit_id is for components, but it's not there on the data tables.
To be honest I haven't written any unit tests before (only automation stuff), so I was checking out other ways to test it.

@nursix
Copy link
Member

nursix commented Oct 13, 2015

A unit test would create a test req_commit record, and then run req_CommitRepresent against the record ID. Then check whether the return value is correct, and finally remove the test record.

That's all there is to it, nothing fancy.

@nursix
Copy link
Member

nursix commented Oct 13, 2015

There are over 500 examples of unit tests in modules/unit_tests and plenty of documentation for the Python unittest module. It's not rocket science - the trick is just to understand what you're trying to prove with the test and implement a valid test.

@nursix
Copy link
Member

nursix commented Oct 13, 2015

And I said that with the unittest only to spare you the effort of digging for a case where it is visible, because I understood that you couldn't find one. In fact, there may not be one ;)

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