Ozon3Org / Ozon3

An open-source Python package to easily obtain real-time, historical, or forecasted air quality data for anywhere in the world. Reliable, accurate and simple.
GNU General Public License v3.0
66 stars 23 forks source link

Add tests suite #120

Closed lahdjirayhan closed 2 years ago

lahdjirayhan commented 2 years ago

This PR is currently working in progress, to fix #8.

List of public methods to write tests of:

In summary:

This PR should also:

Potential discussion points:

Milind220 commented 2 years ago

Great PR! Gonna be really awesome to have a testing suite, and this one looks really comprehensive :)

Should we use tox for doing the tests? Especially in light of error discovered in https://github.com/Milind220/Ozone/issues/119

I'm going to read up on tox, seeing as I don't currently know what it is. I'm assuming it helps catch errors that may crop up in the process of packaging and importing?

lahdjirayhan commented 2 years ago

Some caveats about the tests and cassettes:

  1. The tests are not written in a way that current Ozone will just pass. I've used my best judgments when exploring/writing the tests. It feels different when writing tests vs when writing code.
  2. Some cassettes are (unluckily? luckily?) getting some quirky edge cases that throws error. I've never encountered this behavior in particular: Paris' AQI is given out as "-" a string, with just a hyphen in it. I get that it's supposed to mean NA, maybe, but it throws a ValueError: could not convert string to float: '-' that I've never seen before.
  3. There is an uncaught bug in current Ozone! Try using get_range_coordinates_air, and you'll see (I compare it with v1.5.0 tag, there was no error there). This error is likely missed when refactoring the code.

My suggestion to go about this:

  1. I recommend fixing Ozone to pass the tests than the other way around. They're mostly minor aspects, but please do check the failing tests anyway.
  2. I recommend fixing Ozone to handle such edge cases, and leave the cassettes as it is (not re-record). Let's just say we're lucky to have an edge case in our cassette. But re-recording them would be fine anyway.
  3. This has to be fixed asap.

@Milind220 Given we're both new to tox, I think we should focus on the test suite as it is and think about it in another time. Sorry for raising it earlier, it felt like I've bothered you and overcomplicated the PR unnecessarily. 🙏🏼

Milind220 commented 2 years ago
  1. There is an uncaught bug in current Ozone! Try using get_range_coordinates_air, and you'll see (I compare it with v1.5.0 tag, there was no error there). This error is likely missed when refactoring the code.

Oh yikes! Great that we have tests now though :)

My suggestion to go about this:

  1. I recommend fixing Ozone to pass the tests than the other way around. They're mostly minor aspects, but please do check the failing tests anyway.

I absolutely agree, tests will ensure that Ozone's code is up to a decent standard.

  1. I recommend fixing Ozone to handle such edge cases, and leave the cassettes as it is (not re-record). Let's just say we're lucky to have an edge case in our cassette. But re-recording them would be fine anyway.
  2. This has to be fixed asap.

Let's leave the cassettes as they are, and fix the bugs asap for sure.

@Milind220 Given we're both new to tox, I think we should focus on the test suite as it is and think about it in another time. Sorry for raising it earlier, it felt like I've bothered you and overcomplicated the PR unnecessarily. 🙏🏼

No worries, we can always add it in another time.

Awesome work! I went through the tests and they look really solid and well formulated. Can't wait to see Ozone'd code quality improve with the tests checking :)

Milind220 commented 2 years ago

@lahdjirayhan Just to confirm, this PR is complete right? I do have a couple questions.

lahdjirayhan commented 2 years ago

Just to confirm, this PR is complete right?

Yes. Feel free to merge if you think it's enough.

What is the current mechanism to run these tests? Do we run them on locally on our own computers?

Yes. Each developer can verify and test their work locally and automatically (not manually test each cases one by one).

We still have to add continuous testing integration right?

Yep. It's not included in this PR.