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

Un dev #63

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Un dev #63

wants to merge 16 commits into from

Conversation

uyennguyen16900
Copy link
Collaborator

@uyennguyen16900 uyennguyen16900 commented Jul 25, 2020

doorknob/test_detect.py

All tests pass, except the first one.
I set the region to us-west-1, but I don't know why the regions for "SigningCertURL" and "UnsubscribeURL" are us-east-1.

In line 63 I compare acquired_message dict with expected dict.
Here is the output for print(acquired_message)

{
  "Message": "my message",
  "MessageId": "d118ecc5-6dc3-4b38-bb09-2514d6ae53eb",
  "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpi
j7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
  "SignatureVersion": "1",
  "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
  "Subject": "my subject",
  "Timestamp": "2020-07-24T12:00:00.000Z",
  "TopicArn": "arn:aws:sns:us-west-1:123456789012:some-topic",
  "Type": "Notification",
  "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:12345678
9012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
}

Here is the output for print(expected)

{
  "Message": "my message",
  "MessageId": "19615f43-f2a4-416f-a6ee-3e02deb83fba",
  "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpi
j7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
  "SignatureVersion": "1",
  "SigningCertURL": "https://sns.us-west-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
  "Subject": "my subject",
  "Timestamp": "2020-07-24T12:00:00.000Z",
  "TopicArn": "arn:aws:sns:us-west-1:123456789012:some-topic",
  "Type": "Notification",
  "UnsubscribeURL": "https://sns.us-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-1:12345678
9012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
}

.travis.yml Outdated
Comment on lines 15 to 19
<<<<<<< HEAD
- flake8
=======
- flake8 --exclude=doorknob/__init__.py,migrations
>>>>>>> c7b73082a79eef302b7168ff3e80dc3c2293398b
Copy link
Collaborator

Choose a reason for hiding this comment

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

@uyennguyen16900 , it looks like you changed the command for flake8 on your branch. Was the previous command (the one that says - flake8 --exclude=doorknob/__init__.py,migrations giving you errors?

In it's current state these 5 lines will cause a merge conflict, so if there are no errors using the 2nd command I think we should choose that over the basic - flake8, as it skips over certain files during testing that we don't need to worry about.

aws_data: A list of detected face json objects generated by AWS
Rekognition.
aws_data: A list of detected face json objects generated by AWS Rekognition.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I appreciate that you made the docstring look simpler @uyennguyen16900 . However this line 16 is a little long, it is 85 characters and the Pep 8 standard is to keep it below 80. You don't need to make it go onto the next line, but you please try and make the line length < 80 somehow?

@@ -1,8 +1,7 @@
import json
import unittest

from doorknob.foyer import Scene

from foyer import Scene
Copy link
Collaborator

Choose a reason for hiding this comment

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

Importing from a higher level package in Python 3 is pretty tricky, and when I ran pytest on my machine this line caused a ModuleNotFoundError. However, could you try switching this line to from doorknob.foyer import Scene. Then, please verify with pytest that all the errors are resolved.

Copy link
Collaborator Author

@uyennguyen16900 uyennguyen16900 Jul 25, 2020

Choose a reason for hiding this comment

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

I had no module error because they are not in the same package. That's why I moved test_detect.py to its parent folder.

@UPstartDeveloper UPstartDeveloper self-assigned this Jul 25, 2020
@UPstartDeveloper UPstartDeveloper added the bug Something isn't working label Jul 25, 2020
@UPstartDeveloper UPstartDeveloper added this to In progress in Engineering Sprints via automation Jul 25, 2020
@UPstartDeveloper UPstartDeveloper added this to the User Dashboard milestone Jul 25, 2020
@UPstartDeveloper UPstartDeveloper linked an issue Jul 25, 2020 that may be closed by this pull request
Comment on lines 6 to 9
from freezegun import freeze_time
from detect import VideoDetect

from moto import mock_sns, mock_sqs
Copy link
Collaborator

Choose a reason for hiding this comment

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

The imports in these lines are also causing ModuleNotFound errors. Would you please make sure to freeze your requirements on requirements/local.txt and requirements/production.txt files if you installed new packages?

watch/tests.py Outdated
Comment on lines 1 to 8
from django.test import Client, TestCase
from django.test import TestCase, Client
from django.test.client import RequestFactory
from watch.views import HomeView
from django.urls import reverse, reverse_lazy
from .views import (
HomeView,
WatchedView,
)
from django.core.files.uploadedfile import SimpleUploadedFile
Copy link
Collaborator

@UPstartDeveloper UPstartDeveloper Jul 25, 2020

Choose a reason for hiding this comment

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

Run isort watch/tests.py to double check the order of your imports is correct.

@@ -34,6 +45,7 @@ <h1 class="display-4">Measure User Satisfaction</h1>
</div>
<!--end of container-->
<!--end of section-->
>>>>>>> c7b73082a79eef302b7168ff3e80dc3c2293398b
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lines 11-48 shows that we have another merge conflict. When I ran this on localhost, the upload button on your branch is not as stylish as the one on the master.

Did you experience any error with the version of the upload button currently on master @uyennguyen16900? I think if it's possible we should just keep the upload button as is, as it will look better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm sure why we have a merge conflict here since I haven't changed anything in html files.

Copy link
Collaborator

@UPstartDeveloper UPstartDeveloper Jul 25, 2020

Choose a reason for hiding this comment

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

Oh it's no problem. The conflict is probably because you just might not have pulled from the master branch in a while, because I'm assuming this branch was created a while back, before we integrated the Bootstrap theme into the HTML.


expected = MESSAGE_FROM_SQS % (message, published_message_id, "us-west-1")
acquired_message = re.sub(
"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting thing I learned about about Regular Expressions:

It is considered best practice to prepend your regex with an "r" - this helps the linter from throwing weird errors, such as thinking the "\d" is an escape sequence or something like that.

You can read more about that on this page from Flake8 Rules.

@UPstartDeveloper UPstartDeveloper marked this pull request as ready for review July 25, 2020 19:03
Comment on lines 5 to 8
<<<<<<< HEAD
=======

>>>>>>> 7947f58b3010bd6e94e4351e2d33a23f81608875
Copy link
Collaborator

Choose a reason for hiding this comment

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

@uyennguyen16900 please delete lines 5, 6, and 8. The git diff markers need to be removed, as they will cause the tests to fail.

@@ -16,6 +20,7 @@ def test_no_emotions(self):
with self.assertRaises(ValueError):
Scene(aws_data=json.load(f))


class VideoDetectTestCase(unittest.TestCase):
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can delete this class declaration now, since I see that you already have the tests for VideoDetect in another file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ran the SceneTestCase test class and they failed.

Copy link
Collaborator

@UPstartDeveloper UPstartDeveloper left a comment

Choose a reason for hiding this comment

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

Hey @uyennguyen16900 - this PR is awesome.

Only some minor changes are needed, see my comments to help you because they mainly have to do with formatting.

Also, be sure to run black . at the top level of your local repo, so it can auto-fix some formatting errors. The command flake8 --exclude=migrations,env will also help highlight these for you.

Right now the main problem with the tests is in test_tasks.py, on line 7 when you call the reverse() with "run_task" as the argument. My question is: is the reverse function being used supposed to come from Django, or does it come from another library? Because right now the test thinks the argument is supposed to be the name of a view, and it fails because it can't find it.

Kudos for learning the moto package all by yourself!

Engineering Sprints automation moved this from In progress to Review in progress Jul 25, 2020
@uyennguyen16900
Copy link
Collaborator Author

Hey @uyennguyen16900 - this PR is awesome.

Only some minor changes are needed, see my comments to help you because they mainly have to do with formatting.

Also, be sure to run black . at the top level of your local repo, so it can auto-fix some formatting errors. The command flake8 --exclude=migrations,env will also help highlight these for you.

Right now the main problem with the tests is in test_tasks.py, on line 7 when you call the reverse() with "run_task" as the argument. My question is: is the reverse function being used supposed to come from Django, or does it come from another library? Because right now the test thinks the argument is supposed to be the name of a view, and it fails because it can't find it.

Kudos for learning the moto package all by yourself!

test_task.py is not working right now. I'm still playing around with it. My apologies for pushing incomplete tests. I had to commit everything I was working on in order to pull from master.

@UPstartDeveloper
Copy link
Collaborator

Oh no you're good! I was just curious in case the moto package had its own reverse function or something.

Code review is a good learning opportunity for both people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Engineering Sprints
  
Review in progress
Development

Successfully merging this pull request may close these issues.

Add Unit Testing Coverage
2 participants