Example #1
0
def link(user):
    is_link = db.get_link(URL_CHECK)
    if is_link:
        db.delete_link(is_link.id)

    name = URL_NAME
    url = URL_CHECK
    description = 'test'
    username = user.username
    yield db.create_link(name, url, description, username)
Example #2
0
def get_link(tinyurl):
    '''Get link affiliated to tinyurl in the database
    and redirect response to the link
    '''
    data = db.get_link(tinyurl)
    if data:
        return redirect(data[1], code=302)
    else:
        return jsonify(
            {'message': '{} is not a registered T**s'.format(tinyurl)})
Example #3
0
    def test_create_link(user):
        link = db.get_link(TestLinks.URL_CHECK)
        if link:
            db.delete_link(link.id)

        name = TestLinks.URL_NAME
        url = TestLinks.URL_CHECK
        description = 'test'
        username = user.username

        assert bool(db.create_link(name, url, description, username)) == True
Example #4
0
File: add.py Project: ericgj/bookm
def run(args):
  dt = int(time())
  title = args.title
  tags = args.tags
  url = args.url
  input = (
    edit_link(title,url,'',tags)
      .fmap(parse_link_form)
      .fmap(merge({u'date': dt, u'link': url}))
  )

  task = (
    db.connect() 
      >> ( lambda cnn: (
             ( input 
                 >> flip(db.upsert_link)(cnn) )
                 >> always(db.get_link(url,cnn)) )
         )
  )

  task.fork(handle_error, handle_success)
Example #5
0
 def test_not_get_link():
     url = "www.notaurl.com"
     assert db.get_link(url) == False
Example #6
0
 def test_get_link(link):
     assert bool(db.get_link(link.url)) == True