Exemplo n.º 1
0
 def test_fetch_expired_consented_attributes(self):
     id = "test"
     consented_attributes = ['a', 'b', 'c']
     consent = Consent(consented_attributes, 2,
                       datetime.now() - timedelta(weeks=14))
     assert consent.has_expired(self.max_month)
     self.consent_db.save_consent(id, consent)
     assert not self.cm.fetch_consented_attributes(id)
Exemplo n.º 2
0
    def get_consent(self, id: str) -> Consent:
        hashed_id = hash_id(id, self.salt)
        result = self.consent_table.find_one(consent_id=hashed_id)
        if not result:
            return None

        consent = Consent(json.loads(result['attributes']), result['months_valid'],
                          datetime.strptime(result['timestamp'], ConsentDatasetDB.TIME_PATTERN))
        if consent.has_expired(self.max_month):
            self.remove_consent(id)
            return None
        return consent
Exemplo n.º 3
0
    def get_consent(self, id: str) -> Consent:
        hashed_id = hash_id(id, self.salt)
        result = self.consent_table.find_one(consent_id=hashed_id)
        if not result:
            return None

        consent = Consent(
            json.loads(result['attributes']), result['months_valid'],
            datetime.strptime(result['timestamp'],
                              ConsentDatasetDB.TIME_PATTERN))
        if consent.has_expired(self.max_month):
            self.remove_consent(id)
            return None
        return consent
Exemplo n.º 4
0
 def test_consent_has_expired(self, mock_datetime, current_time, month,
                              max_month):
     mock_datetime.now.return_value = current_time
     start_date = datetime.datetime(2015, 1, 1)
     consent = Consent(None, month, timestamp=start_date)
     assert consent.has_expired(max_month)
Exemplo n.º 5
0
 def test_consent_has_expired(self, mock_datetime, current_time, month, max_month):
     mock_datetime.now.return_value = current_time
     start_date = datetime.datetime(2015, 1, 1)
     consent = Consent(None, month, timestamp=start_date)
     assert consent.has_expired(max_month)