text: import pytest
  from datetime import datetime
  import pytz
  
  from edgeauth.digest_tokens import DigestTokens
  from edgeauth.token_builder import TokenBuilder
  
  
  class TestWhenVerifyingATokenForARoom:
      token = None
  
      @pytest.fixture(autouse=True)
      def before_each(self):
          self.token = TokenBuilder() \
              .with_application_id('my-application-id') \
              .with_secret('my-secret') \
              .expires_at(datetime.utcfromtimestamp(1.0).replace(tzinfo=pytz.UTC)) \
              .for_room('my-room.123456') \
              .for_streaming_only() \
              .build()
  
      def test_token_matches_expected_value(self):
          assert self.token == 'DIGEST:eyJhcHBsaWNhdGlvbklkIjoibXktYXBwbGljYXRpb24taWQiLCJkaWdlc3QiOiI2WWdud09qWkx4Mk8zQXJjd29CUlVKU0UyYkRVNWVGY0FIYjI3OEJxVlMvcmplMXlsRU51bE5BSTVqakd2Mjc3VnZTTEtkYk1jTW1HenA3Nm9wNkNmZz09IiwidG9rZW4iOiJ7XCJleHBpcmVzXCI6MTAwMCxcInJlcXVpcmVkVGFnXCI6XCJyb29tSWQ6bXktcm9vbS4xMjM0NTZcIixcInR5cGVcIjpcInN0cmVhbVwifSJ9'
  
      def test_the_token_successfully_verifies_with_the_correct_secret(self):
          result = DigestTokens() \
              .verify_and_decode('my-secret', self.token)
  
          assert result['verified'] is True
          assert result['code'] == 'verified'
          assert 'value' in result
  
          value = result['value']
  
          assert value['requiredTag'] == 'roomId:my-room.123456'
  
      def test_the_token_fails_to_verify_with_a_bad_secret(self):
          result = DigestTokens() \
              .verify_and_decode('bad-secret', self.token)
  
          assert result['verified'] is False
          assert result['code'] == 'bad-digest'
          assert 'value' not in result
  