def testClientSpecificPrecompute(self): for email in self.testUsers: currUser = User.fromEmail(email) self.assertEqual(currUser.getProfile().get("testfield1"), None) self.assertEqual(currUser.getProfile().get("testfield2"), None) self.assertEqual(data.getCarbonFootprint(currUser), None) fakeEmail = "*****@*****.**" client = Client("testclient") client.update(createKey=False) emission.tests.common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", fakeEmail) user = User.fromEmail(fakeEmail) self.assertEqual(user.getFirstStudy(), 'testclient') self.pr.precomputeResults() self.assertEqual(user.getProfile()['testfield1'], 'value1') self.assertEqual(user.getProfile()['testfield2'], 'value2') for email in self.testUsers: if email != fakeEmail: currUser = User.fromEmail(email) carbonFootprint = data.getCarbonFootprint(currUser) self.assertEqual(len(carbonFootprint), 12)
def testClientSpecificPrecompute(self): for email in self.testUsers: currUser = User.fromEmail(email) self.assertEqual(currUser.getProfile().get("testfield1"), None) self.assertEqual(currUser.getProfile().get("testfield2"), None) self.assertEqual(data.getCarbonFootprint(currUser), None) fakeEmail = "*****@*****.**" client = Client("testclient") client.update(createKey = False) emission.tests.common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", fakeEmail) user = User.fromEmail(fakeEmail) self.assertEqual(user.getFirstStudy(), 'testclient') self.pr.precomputeResults() self.assertEqual(user.getProfile()['testfield1'], 'value1') self.assertEqual(user.getProfile()['testfield2'], 'value2') for email in self.testUsers: if email != fakeEmail: currUser = User.fromEmail(email) carbonFootprint = data.getCarbonFootprint(currUser) self.assertEqual(len(carbonFootprint), 12)
def testCarbonFootprintStore(self): user = User.fromUUID(self.uuid) # Tuple of JSON objects, similar to the real footprint dummyCarbonFootprint = ({'myModeShareCount': 10}, {'avgModeShareCount': 20}) self.assertEquals(data.getCarbonFootprint(user), None) data.setCarbonFootprint(user, dummyCarbonFootprint) # recall that pymongo converts tuples to lists somewhere down the line self.assertEquals(data.getCarbonFootprint(user), list(dummyCarbonFootprint))
def testCarbonFootprintStore(self): user = User.fromUUID(self.uuid) # Tuple of JSON objects, similar to the real footprint dummyCarbonFootprint = ({ 'myModeShareCount': 10 }, { 'avgModeShareCount': 20 }) self.assertEquals(data.getCarbonFootprint(user), None) data.setCarbonFootprint(user, dummyCarbonFootprint) # recall that pymongo converts tuples to lists somewhere down the line self.assertEquals(data.getCarbonFootprint(user), list(dummyCarbonFootprint))