コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
ファイル: TestData.py プロジェクト: juemura/e-mission-server
 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))
コード例 #4
0
 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))