Coverage for tests/tests_helpers.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.10.2, created at 2025-08-05 22:06 +0000

1import unittest 

2import os 

3import hashlib 

4 

5from webapp import helpers 

6from webapp.app import create_app 

7from flask_testing import TestCase 

8 

9 

10class GetDnsVerificationTokenTest(unittest.TestCase): 

11 def test_get_dns_verification_token(self): 

12 salt = os.getenv("DNS_VERIFICATION_SALT") 

13 token_string = f"spotify.com:spotify:{salt}" 

14 test_hash = hashlib.sha256(token_string.encode("utf-8")).hexdigest() 

15 self.assertEqual( 

16 helpers.get_dns_verification_token("spotify", "spotify.com"), 

17 test_hash, 

18 ) 

19 

20 

21class DirectoryExistsTest(TestCase): 

22 def create_app(self): 

23 app = create_app(testing=True) 

24 return app 

25 

26 def test_directory_exists(self): 

27 filename = "first_snap/content/c" 

28 self.assertTrue(helpers.directory_exists(filename)) 

29 

30 def test_directory_not_exists(self): 

31 filename = "first_snap/content/test" 

32 self.assertFalse(helpers.directory_exists(filename))