Esempio n. 1
0
    def test_get_returns_default_form(self):
        from stickercode.views import LabelViews

        request = testing.DummyRequest()
        inst = LabelViews(request)
        result = inst.qr_label()
        self.assertIsNone(result.get("appstruct"))
Esempio n. 2
0
    def test_serial_and_domain_is_passing(self):
        from stickercode.views import LabelViews

        post_dict = {"submit":"submit", "serial":"UT5555",
                     "domain":"https://waspho.com"}
        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()
        self.assertIsNotNone(result.get("appstruct"))
Esempio n. 3
0
    def test_post_fully_populated_creates_hardcoded_filename(self):
        from stickercode.views import LabelViews

        post_dict = {"submit":"submit", "serial":"UT5555",
                     "domain":"https://waspho.com"}
        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()
        
        dest_file = "label_files/ut5555/label.png"
        self.assertTrue(file_range(dest_file, 15118))
Esempio n. 4
0
    def test_malformed_domain_is_failure(self):
        from stickercode.views import LabelViews

        bad_domains = ["http://", "http", "htt p://waspho.com", ".com"]
        for item in bad_domains:
            post_dict = {"submit":"submit", "serial":"UT5555",
                         "domain":item}
            request = testing.DummyRequest(post_dict)
            inst = LabelViews(request)
            result = inst.qr_label()
            self.assertIsNone(result.get("appstruct")) 
Esempio n. 5
0
    def test_unknown_sticker_serial_view_is_failure(self):
        from stickercode.views import LabelViews

        request = testing.DummyRequest()
        request.matchdict["serial"] = "badSerial1"
        inst = LabelViews(request)
        self.assertRaises(OSError, inst.show_label)
Esempio n. 6
0
    def test_post_with_image_creates_hardcoded_filename(self):
        from stickercode.views import LabelViews
    
        png_name = "resources/inverted_wasatch.png"
        png_file = DeformMockFieldStorage(png_name)
        png_upload_dict = {"upload":png_file}
 
        post_dict = {"submit":"submit", "serial":"UT5555",
                     "domain":"https://waspho.com",
                     "upload":png_upload_dict}
        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()
        
        dest_top = "label_files/ut5555/custom_background.png"
        self.assertTrue(file_range(dest_top, 63692))
Esempio n. 7
0
    def test_post_with_invalid_background_size_uses_default(self):
        from stickercode.views import LabelViews
        
    
        png_name = "resources/wrong_size_wasatch.png"
        png_file = DeformMockFieldStorage(png_name)
        png_upload_dict = {"upload":png_file}
 
        post_dict = {"submit":"submit", "serial":"UT5555",
                     "domain":"https://waspho.com",
                     "upload":png_upload_dict}

        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()

        dest_file = "label_files/ut5555/label.png"
        self.assertTrue(file_range(dest_file, 15118))
Esempio n. 8
0
    def test_serial_missing_or_empty_is_failure(self):
        from stickercode.views import LabelViews

        post_dict = {"submit":"submit"}
        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()
        self.assertIsNone(result.get("appstruct")) 

        post_dict = {"submit":"submit", "serial":""}
        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()
        self.assertIsNone(result.get("appstruct")) 
Esempio n. 9
0
    def test_post_fully_populated_sticker_view_accessible(self):
        from stickercode.views import LabelViews

        post_dict = {"submit":"submit", "serial":"UT5555",
                     "domain":"https://waspho.com"}
        request = testing.DummyRequest(post_dict)
        inst = LabelViews(request)
        result = inst.qr_label()
       
        request = testing.DummyRequest()
        request.matchdict["serial"] = "UT5555"
        inst = LabelViews(request)
        result = inst.show_label()

        file_size = result.content_length
        self.assertTrue(size_range(file_size, 15118))