Skip to content

Commit

Permalink
✅ Register the users before running the pipeline tests
Browse files Browse the repository at this point in the history
In 0403ae0, we start precomputing the pipeline
stage and storing it in this profile. This means that we need the user to have
a profile to begin with.

In the real world, users will always have profiles since we register them
during `profile/create`

In this test, we set the `testEmail` so that we register the users as part of
the test as well. This implies that we also:
- need to delete the profile_db() as part of cleanup
- use the version of the pipeline in `epi` so that it will run the pre-population code

Once we do that, the tests pass. However, when they were failing, we realized
that we can't compare two tuples with `assertAlmostEqual` since the assertion
can't subtract tuples to get the difference. Instead, we separate out the start
and end and compare them independently with `assertAlmostEqual`

Testing done:
both tests pass

```
----------------------------------------------------------------------
Ran 2 tests in 33.884s

OK
```
  • Loading branch information
shankari committed Aug 15, 2023
1 parent 0e4fe47 commit 2099f9b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions emission/tests/netTests/TestPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
import emission.core.get_database as edb
import emission.core.wrapper.localdate as ecwl
import emission.tests.common as etc
import emission.pipeline.intake_stage as epi

from emission.net.api import pipeline

class TestPipeline(unittest.TestCase):
def setUp(self):
self.testEmail="[email protected]"
etc.setupRealExample(self,
"emission/tests/data/real_examples/shankari_2015-aug-21")
self.testUUID1 = self.testUUID
self.testEmail="[email protected]"
etc.setupRealExample(self,
"emission/tests/data/real_examples/shankari_2015-aug-27")

Expand All @@ -22,6 +25,7 @@ def tearDown(self):

def clearRelatedDb(self):
edb.get_timeseries_db().delete_many({"user_id": self.testUUID})
edb.get_profile_db().delete_many({"user_id": self.testUUID})
edb.get_analysis_timeseries_db().delete_many({"user_id": self.testUUID})
edb.get_pipeline_state_db().delete_many({"user_id": self.testUUID})
edb.get_timeseries_db().delete_many({"user_id": self.testUUID1})
Expand All @@ -33,8 +37,10 @@ def testNoAnalysisResults(self):

def testAnalysisResults(self):
self.assertEqual(pipeline.get_range(self.testUUID), (None, None))
etc.runIntakePipeline(self.testUUID)
self.assertAlmostEqual(pipeline.get_range(self.testUUID), (1440688739.672, 1440729142.709))
epi.run_intake_pipeline_for_user(self.testUUID, skip_if_no_new_data = False)
pr = pipeline.get_range(self.testUUID)
self.assertAlmostEqual(pr[0], 1440688739.672)
self.assertAlmostEqual(pr[1], 1440729142.709)

if __name__ == '__main__':
import emission.tests.common as etc
Expand Down

0 comments on commit 2099f9b

Please sign in to comment.