From 9ce5566045dc8cba1194def1bae911cc81380bc8 Mon Sep 17 00:00:00 2001
From: Klimin Mike <klinkin@gmail.com>
Date: Sat, 8 Feb 2014 04:18:49 +0400
Subject: [PATCH] Add new tests to provide bug if blueprint with subdomain

---
 tests/test_flask_static.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/tests/test_flask_static.py b/tests/test_flask_static.py
index b1831db..7e52727 100644
--- a/tests/test_flask_static.py
+++ b/tests/test_flask_static.py
@@ -55,9 +55,14 @@ def b():
         bp = Blueprint('admin', __name__, static_folder='admin-static')
         @bp.route('/<url_for_string>')
         def c():
-            return render_template_string("{{url_for('b')}}")
+            return render_template_string("{{url_for('c')}}")
         self.app.register_blueprint(bp)
 
+        bp_with_subdomain = Blueprint('settings', __name__, static_folder='billing-static', subdomain='billing')
+        @bp_with_subdomain.route('/<url_for_string>')
+        def d():
+            return render_template_string("{{url_for('d')}}")
+        self.app.register_blueprint(bp_with_subdomain)
 
     def client_get(self, ufs):
         FlaskS3(self.app)
@@ -121,6 +126,21 @@ def test_url_for_cdn_domain(self):
         exp = 'https://foo.cloudfront.net/static/bah.js'
         self.assertEquals(self.client_get(ufs).data, exp)
 
+    def test_url_for_blueprint_with_subdomain(self):
+        """
+        Tests that correct url formed for static asset in blueprint with subdomain.
+        """
+        # static endpoint url_for in template
+        ufs = "{{url_for('settings.static', filename='bah.js')}}"
+        exp = 'https://foo.s3.amazonaws.com/billing/billing-static/bah.js'
+        self.assertEquals(self.client_get(ufs).data, exp)
+
+
+    def test_url_for_cdn_domain_for_blueprint_with_subdomain(self):
+        self.app.config['S3_CDN_DOMAIN'] = 'foo.cloudfront.net'
+        ufs = "{{url_for('settings.static', filename='bah.js')}}"
+        exp = 'https://foo.cloudfront.net/billing/billing-static/bah.js'
+        self.assertEquals(self.client_get(ufs).data, exp)
 
 
 class S3Tests(unittest.TestCase):