1
1
"""Test file for storage functions."""
2
+ from unittest import TestCase
2
3
3
4
from app .api .helpers .storage import create_url
4
- from tests .unittests .setup_database import Setup
5
- from tests .unittests .utils import OpenEventTestCase
6
5
7
6
8
- class TestStorageHelperValidation (OpenEventTestCase ):
7
+ class TestStorageHelperValidation (TestCase ):
9
8
"""Test class for testing storage helper functions."""
10
9
11
- def setUp (self ):
12
- """Method to set up app for testing."""
13
- self .app = Setup .create_app ()
14
-
15
- def test_create_url (self ):
16
- """Method to test the create_url function."""
10
+ def test_arbitrary_url (self ):
11
+ """Method to test a url with arbitrary port."""
17
12
18
13
request_url = 'https://localhost:5000'
19
14
file_relative_path = '/some/path/image.png'
@@ -22,13 +17,19 @@ def test_create_url(self):
22
17
self .assertEqual (
23
18
create_url (request_url , file_relative_path ), expected_file_url
24
19
)
25
- request_url = 'https://localhost:443'
26
- expected_file_url = 'https://localhost/some/path/image.png'
27
- self .assertEqual (
28
- create_url (request_url , file_relative_path ), expected_file_url
29
- )
20
+
21
+ def test_http_url (self ):
22
+ """Method to test a url with port 80."""
30
23
request_url = 'http://localhost:80'
31
24
expected_file_url = 'http://localhost/some/path/image.png'
32
25
self .assertEqual (
33
- create_url (request_url , file_relative_path ), expected_file_url
26
+ create_url (request_url , '/some/path/image.png' ), expected_file_url
27
+ )
28
+
29
+ def test_https_url (self ):
30
+ """Method to test a url with port 443."""
31
+ request_url = 'https://localhost:443'
32
+ expected_file_url = 'https://localhost/some/path/image.png'
33
+ self .assertEqual (
34
+ create_url (request_url , '/some/path/image.png' ), expected_file_url
34
35
)
0 commit comments