test_sign_request.py 678 B

123456789101112131415161718192021222324
  1. import datetime
  2. from yandex_music.utils.sign_request import get_sign_request
  3. class TestSignRequest:
  4. timestamp = 1668687184
  5. track_id = 4784420
  6. key = 'SUPER_SECRET_KEY'
  7. sign_value = 'vssEEweZhgv2Aud0rdH9maOXUC03ZkZ/hlo6bSRN8Qg='
  8. def test_sign_request(self, monkeypatch):
  9. class FakeDatetime(datetime.datetime):
  10. @classmethod
  11. def now(cls):
  12. return datetime.datetime.fromtimestamp(self.timestamp)
  13. monkeypatch.setattr('datetime.datetime', FakeDatetime)
  14. sign = get_sign_request(self.track_id, self.key)
  15. assert sign.timestamp == self.timestamp
  16. assert sign.value == self.sign_value