예제 #1
0
 def test_insert_invalid_shortcode_failure(self):
     with pytest.raises(
             Exception
     ) as exc:  # Wide catch, scope narrowed for preventing nested Exception override
         Shortcode.insert(shortcode='090')
         assert isinstance(exc.type,
                           InvalidShortcode.__class__)  # Sanity check
예제 #2
0
 def test_insert_shortcode_already_in_use_failure(self):
     with pytest.raises(
             Exception
     ) as exc:  # Wide catch, scope narrowed for preventing nested Exception override
         Shortcode.insert(shortcode='08vs43')
         assert isinstance(exc.type,
                           ShortcodeAlreadyInUse.__class__)  # Sanity check
예제 #3
0
 def test_check_validity_success(self):
     assert Shortcode.check_validity(shortcode='927hs_')
예제 #4
0
 def test_generate_random(self):
     random_string = Shortcode.generate_random()
     assert Shortcode.check_validity(shortcode=random_string)
예제 #5
0
 def test_url_insert_existing_with_shortcode_success(self):
     with self.app.app_context():
         url = Url.insert_url(url='scenario2.com', shortcode='js9_86')
         assert Shortcode.check_validity(shortcode=url)
         assert url == 'js9_86'
예제 #6
0
 def test_url_insert_new_without_shortcode_success(self):
     with self.app.app_context():
         url = Url.insert_url(url='scenario1.com')
         assert Shortcode.check_validity(shortcode=url)
예제 #7
0
 def test_insert_success(self):
     assert isinstance(Shortcode.insert(shortcode='000xzz'), Shortcode)
예제 #8
0
 def test_generate_new(self):
     assert Shortcode.check_validity(shortcode=Shortcode.generate_new())
예제 #9
0
 def test_check_in_use_false(self):
     assert Shortcode.check_in_use('xyzxyz') is False
예제 #10
0
 def test_check_in_use_true(self):
     Url.insert_url(url='scenario5.com', shortcode='08vs43')
     assert Shortcode.check_in_use('08vs43')
예제 #11
0
 def test_check_validity_failure(self):
     assert Shortcode.check_validity(shortcode='poc') is False