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

QA: test - user registration backend api #59

Merged

Conversation

mtreacy002
Copy link
Member

@mtreacy002 mtreacy002 commented Jun 16, 2020

Description

test cases for Register user API

Fixes #54

Type of Change:

  • Quality Assurance

Code/Quality Assurance Only

  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  • by running python -m unittest discover tests on the terminal
  • by running tests from Python and Tests explorers VSCode
    Both resulted in pass

Note: To test the register UI-backend integration/functionality manually, you MUST run BIT frontend server with the PR#24 latest code otherwise it will not work.

Screen Shot 2020-06-16 at 8 45 16 pm

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials

Code/Quality Assurance Only

  • My changes generate no new warnings
  • My PR currently breaks something (fix or feature that would cause existing functionality to not work as expected)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Note:
Travis-build failed but caused by unrelated issue (can't create test database through Travis)

@mtreacy002
Copy link
Member Author

@anitab-org/bridgeintech-maintainers , can you please advice if this is ok? only done one test for now coz I want to see if it's ok before writing the next test cases. Also, there's issue with travis build as i mentioned above. can you pls guide me on how to troubleshoot this?

@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . Here's the latest test cases (minus Internal server error)

will add that soon.

The tests done locally has passed successfully

Screen Shot 2020-06-18 at 3 07 42 pm

@mtreacy002 mtreacy002 self-assigned this Jun 18, 2020
@mtreacy002 mtreacy002 added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Category: Quality Assurance Changes to code or files that improve testing or fixes bugs. Program: GSOC Related to work completed during the Google Summer of Code Program. labels Jun 18, 2020
@mtreacy002 mtreacy002 added this to the GSoc: Coding Phase 1 milestone Jun 18, 2020
@mtreacy002
Copy link
Member Author

I just realized that the response from ConnectionError using the old code will get display in its original HTTP response (unmasked ~ not a customised response from BIT or MS). This is the standard HTTP with json data in them.

With old code:
Screen Shot 2020-06-19 at 8 15 02 am

Screen Shot 2020-06-19 at 8 17 51 am

With latest code (masked response)

Screen Shot 2020-06-19 at 8 38 56 am

So, I'm just fixing the actual code at the same time (thanks to testing, we catch the bug early) 😂.

Although just now I changed the code back to matching old code for Exception error since this type of error will have a json response in it.

Screen Shot 2020-06-19 at 9 02 14 am

I just didn't have time to write a test for this random exception since my focus is to test the listed items first for the time constraint sake.

cc @anitab-org/bridgeintech-maintainers

@mtreacy002 mtreacy002 requested review from ramitsawhney27 and a team June 19, 2020 00:21
@mtreacy002 mtreacy002 changed the title WIP: test - user registration backend api QA: test - user registration backend api Jun 19, 2020
Copy link

@meenakshi-dhanani meenakshi-dhanani left a comment

Choose a reason for hiding this comment

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

I have checked the tests covered(good coverage) and the Travis build is also passing.

@meenakshi-dhanani
Copy link

@ramitsawhney27 can you review?

@mtreacy002
Copy link
Member Author

I have checked the tests covered(good coverage) and the Travis build is also passing.

Thanks, @meenakshi-dhanani for your review. 😉

run.py Show resolved Hide resolved
app/api/ms_api_utils.py Show resolved Hide resolved
tests/test_app_config.py Outdated Show resolved Hide resolved
tests/users/test_api_register.py Outdated Show resolved Hide resolved
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers. I've just added validation check to Register user functionality. forgot to put it there for some reason 😊

app/api/ms_api_utils.py Show resolved Hide resolved
app/api/resources/users.py Show resolved Hide resolved
app/api/resources/users.py Show resolved Hide resolved

if is_valid != {}:
return is_valid, HTTPStatus.BAD_REQUEST

# send POST /register request to MS API and return response

Choose a reason for hiding this comment

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

Line gaps seem inconsistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, fixed it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this ok for code readability? since the line shows separation of logic. or should I put all logic together without line gaps?

Screen Shot 2020-06-22 at 1 02 41 am

config.py Outdated Show resolved Hide resolved
result.json Outdated Show resolved Hide resolved
tests/test_app_config.py Outdated Show resolved Hide resolved
tests/users/test_api_register.py Show resolved Hide resolved
tests/users/test_api_register.py Outdated Show resolved Hide resolved
tests/users/test_api_register.py Show resolved Hide resolved
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers. I've modified all the requested changes. Can you please re-review? Thanks

@mtreacy002 mtreacy002 force-pushed the issue54-register-user-API-tests branch 3 times, most recently from fc07e9d to 966fd7f Compare June 22, 2020 12:25
ramitsawhney27
ramitsawhney27 previously approved these changes Jun 23, 2020
@mtreacy002 mtreacy002 force-pushed the issue54-register-user-API-tests branch from 1f3e8a9 to 9c0621a Compare June 24, 2020 08:24
@mtreacy002
Copy link
Member Author

@meenakshi-dhanani , I've just push the latest change as per your request. Can you please re-review? Thanks

@meenakshi-dhanani
Copy link

Why did we need to force push? Not sure. It could be a separate commit

Copy link

@meenakshi-dhanani meenakshi-dhanani left a comment

Choose a reason for hiding this comment

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

Travis build passes. Tests coverage looks fine to me and code has been reviewed by Ramit.

@meenakshi-dhanani
Copy link

@ramitsawhney27 can you re-review? There was just a formatting change I had asked for. I think that's why you might need to review again

@mtreacy002
Copy link
Member Author

mtreacy002 commented Jun 24, 2020

Why did we need to force push? Not sure. It could be a separate commit

Like I mentioned in our call last night, since I opened new branch from develop to work on namedtuple, I need to pull rebase from this PR #59 branch and PR #60 to make sure my changes for the name tuple won't break the register functionality and its tests. If both PR I pull (59 and 60) have separate commits, those commits from 2 separate branches will intermingle based on whichever got committed first, and it won't be clear where individual commit coming from. That's why I squashed commits into one on each PR and pull rebase it from my namedtuple branch. You can see from the screenshot below:

Screen Shot 2020-06-25 at 9 12 43 am

Can you see why it's better to squash commits in this case? As you can see, it is clear where the commits are coming from (PR #59 Register, #56 from develop branch #60 Test Register). If I left commits separately from PR59 and PR60 branches, you'll see lots of small commits scattered everywhere and not sure where they're coming from (I knew this coz that's the issue I used to face when I started a new PR on top of code base of another PR that is still being reviewed). since I squash merge, this intertwined commits no longer an issue.

@foongminwong
Copy link

Just want to drop a comment here

The changes made in this PR were tested locally. Following are the results:

  1. All possible responses are tested below:

    • Running tests for user regsitration backend api locally
      Screenshot/gif/url:

      Expected Result: The unittest for user registration abckend api should run succecssfully.
      Actual Result: Got an error: psycopg2.errors.InvalidSchemaName: schema "bitschema" does not exist LINE 2: CREATE TABLE bitschema.personal_backgrounds (....

      test-pr-59
  2. Additional comments/notes:

    • Since you have screenshots showing that the test cases are running successfully on your end, I'm guessing something's wrong on my database setup. Will figure out why it can't find the bitschema (I thought I already set them up on the pgAdmin/Postgre)
  3. OS Version: Windows 10

@mtreacy002
Copy link
Member Author

@foongminwong . Try to set the search path on your bit_schema_test database (actually set search path for both bit_schema and bit_schema_test) from your command line, just like what Meena and I did in the travis script below

Screen Shot 2020-06-25 at 2 31 51 pm

@meenakshi-dhanani
Copy link

Why did we need to force push? Not sure. It could be a separate commit

Like I mentioned in our call last night, since I opened new branch from develop to work on namedtuple, I need to pull rebase from this PR #59 branch and PR #60 to make sure my changes for the name tuple won't break the register functionality and its tests. If both PR I pull (59 and 60) have separate commits, those commits from 2 separate branches will intermingle based on whichever got committed first, and it won't be clear where individual commit coming from. That's why I squashed commits into one on each PR and pull rebase it from my namedtuple branch. You can see from the screenshot below:

Screen Shot 2020-06-25 at 9 12 43 am

Can you see why it's better to squash commits in this case? As you can see, it is clear where the commits are coming from (PR #59 Register, #56 from develop branch #60 Test Register). If I left commits separately from PR59 and PR60 branches, you'll see lots of small commits scattered everywhere and not sure where they're coming from (I knew this coz that's the issue I used to face when I started a new PR on top of code base of another PR that is still being reviewed). since I squash merge, this intertwined commits no longer an issue.

Problem with small commits scattered everywhere - Let's understand why small commits are important. They help your code become easier to understand, basically dividing your work into small parts. The problem with these being scattered is because they might belong to different PRs, in that case what we usually do is establish a commit format, eg.

[PR #]

so you can always look at a commit and know what PR it is referring to.

About why the small commits might not look that good, is because the messages are not meaningful. If a message is meaningful and indicative of intent, it's always useful to look at those small commits.

In teams and projects, since multiple things are being developed in parallel, you will have occasions when there's a sequence such as this:

#A
#B
#A

There is no need to squash all A's together. And force push and change this. The reality is that work is being done in a parallel fashion, let your history show that.

Conclusion: Have clean commit messages, stick to a format. At work we often use

@mtreacy002
Copy link
Member Author

Ok. I'll do it moving forward then. Thanks for the advice, @meenakshi-dhanani 😉

@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers. I have pull rebased the recent merged to develop branch on this PR.

@mtreacy002 mtreacy002 mentioned this pull request Jun 27, 2020
7 tasks
app/api/ms_api_utils.py Show resolved Hide resolved
app/api/resources/users.py Show resolved Hide resolved
@foongminwong foongminwong merged commit 34ac6e0 into anitab-org:develop Jun 27, 2020
@mtreacy002 mtreacy002 deleted the issue54-register-user-API-tests branch July 6, 2020 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Category: Quality Assurance Changes to code or files that improve testing or fixes bugs. Program: GSOC Related to work completed during the Google Summer of Code Program.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test: Write test cases for Register User API
4 participants