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

Unity tests of logger and devices #142

Merged
merged 24 commits into from
Sep 19, 2019
Merged

Conversation

kevinuehara
Copy link
Contributor

@kevinuehara kevinuehara commented Aug 27, 2019

  • Please check if the PR fulfills these requirements
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Description of PR:

  • Creation of unity tests in python using librarys like pytest, mock, magicmock
  • Refatory Handlers of DeviceManager
  • Refactory connection with Kafka
  • Integration of device-manager with codecov
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • What is the current behavior? (You can also link to an open issue here)

  • What is the new behavior (if this is a feature change)?

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

  • Is there any issue related to this PR in other repository? (such as dojot/dojot)

  • Other information:

@kevinuehara kevinuehara requested a review from a team August 27, 2019 17:08
@codecov
Copy link

codecov bot commented Sep 9, 2019

Codecov Report

❗ No coverage uploaded for pull request base (development@d17b78b). Click here to learn what that means.
The diff coverage is 80.58%.

Impacted file tree graph

@@              Coverage Diff               @@
##             development     #142   +/-   ##
==============================================
  Coverage               ?   73.54%           
==============================================
  Files                  ?       17           
  Lines                  ?     1705           
  Branches               ?        0           
==============================================
  Hits                   ?     1254           
  Misses                 ?      451           
  Partials               ?        0
Impacted Files Coverage Δ
DeviceManager/conf.py 85.71% <ø> (ø)
DeviceManager/KafkaNotifier.py 85.29% <ø> (ø)
DeviceManager/TenancyManager.py 72.91% <100%> (ø)
DeviceManager/SerializationModels.py 85.48% <100%> (ø)
DeviceManager/BackendHandler.py 92.5% <100%> (ø)
DeviceManager/LoggerHandler.py 87.87% <100%> (ø)
DeviceManager/DeviceHandler.py 64.73% <75.29%> (ø)
DeviceManager/ImportHandler.py 83.55% <77.77%> (ø)
DeviceManager/TemplateHandler.py 62.41% <82.6%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d17b78b...cfd2f48. Read the comment docs.

def __init__(self):
pass

@classmethod
def verifyInstance(cls, kafka):
Copy link
Contributor

@mprevide mprevide Sep 10, 2019

Choose a reason for hiding this comment

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

The verifyInstance method repeats in several places. Maybe it could be in one place where the handles extend, like a class. I do not know well.
And maybe it's something more like a getInstance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense. I will improve this instantiation. Thanks!

Copy link
Contributor

@mprevide mprevide Sep 13, 2019

Choose a reason for hiding this comment

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

I don't know much about python.
But I thought more a parent class (for example Handler.py) where all the other somethingHandler could extend them.
And in it would remain in an attribute an instance, without the need to pass the cls, something like a singleton. Maybe it could just use something like a singleton, without the issue of inheritance either. But as I said, I don't know much about python and your solution seems ok to me. @kevinuehara

- Improves instanciation of kafka based on suggested comment
- Updates the unit tests
@mprevide
Copy link
Contributor

mprevide commented Sep 13, 2019

Could you remove the '/test' folder from the statistics?


KafkaHandler().configure(device, meta={"service": 'admin'})

def test_verify_intance_kafka(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add some check to see if it really happened as expected in the above methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check that validates if the function passed the kafka flush in the next commit. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also removed the "/test" folder from the coverage tests :)

'created': '2019-08-29T18:18:07.801602+00:00'}

with patch.object(KafkaInstanceHandler, "getInstance", return_value=MagicMock()):
ImportHandler().notifies_deletion_to_kafka('test_device', 'admin')
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you see if the expected occurred?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check that validates if the function passed the kafka flush remove event in the next commit. Thanks!

'created': '2019-08-29T18:18:07.801602+00:00'}

with patch.object(KafkaInstanceHandler, "getInstance", return_value=MagicMock()):
ImportHandler().notifies_creation_to_kafka(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you see if the expected occurred?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check that validates if the function passed the kafka flush create event in the next commit. Thanks!

Copy link
Contributor

@mprevide mprevide left a comment

Choose a reason for hiding this comment

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

Great job! 😸

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.

None yet

2 participants