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
 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
 def test_check_validity_success(self):
     assert Shortcode.check_validity(shortcode='927hs_')
 def test_generate_random(self):
     random_string = Shortcode.generate_random()
     assert Shortcode.check_validity(shortcode=random_string)
 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'
 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)
 def test_insert_success(self):
     assert isinstance(Shortcode.insert(shortcode='000xzz'), Shortcode)
 def test_generate_new(self):
     assert Shortcode.check_validity(shortcode=Shortcode.generate_new())
 def test_check_in_use_false(self):
     assert Shortcode.check_in_use('xyzxyz') is False
 def test_check_in_use_true(self):
     Url.insert_url(url='scenario5.com', shortcode='08vs43')
     assert Shortcode.check_in_use('08vs43')
 def test_check_validity_failure(self):
     assert Shortcode.check_validity(shortcode='poc') is False