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

Remove unittest.mock from API tests #280

Open
Glutexo opened this issue May 24, 2019 · 1 comment
Open

Remove unittest.mock from API tests #280

Glutexo opened this issue May 24, 2019 · 1 comment

Comments

@Glutexo
Copy link
Collaborator

Glutexo commented May 24, 2019

With host delete (#236) functionality, unittest.mock was added to the API tests. Although mocking is a good thing, we are not using unittest.mock in the API tests. If we were, we could mock out many things, test function calls, possibly even replace the database. But we don’t.

I suggest using one of there two approaches:

  • Use the mock class without unittest.mock. Make it so that it replaces KafkaProducer in tests.
  • Actually use the real Kafka message queue, just use different topics.

I used the former approach in my improvement suggestion branch. It’s more like a driver then, replacing Kafka with a dummy, and it’s similar to how Flask offers its test_client.

The latter one is more similar to how we use a real test database to store and read the records. It’s a dependency, but so is the database, the could be mocked out, but isn’t.

I think we should clearly define the scope and purpose of this test suite and that should determine the way we solve this issue.

(Copy of my inline comment at #238.)

@Glutexo Glutexo changed the title Remove _unittest.mock_ from API tests Remove unittest.mock from API tests May 24, 2019
@Glutexo
Copy link
Collaborator Author

Glutexo commented May 24, 2019

Added to #195.

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

No branches or pull requests

1 participant