def test_get(requests_get):
    sbapi = ScrapboxAPI()
    sbapi.cookie_connect_sid = 'secret'
    sbapi.project_id = 'some_project'
    sbapi.get('some-meme')
    requests_get.assert_called_with(
        'https://scrapbox.io/api/pages/'
        'some_project/some-meme',
        cookies={'connect.sid': 'secret'})
 def summarize(self, meme, page, related):
     sbapi = ScrapboxAPI(parent=self.nb_app)
     has_page = 1 if page is not None else 0
     count = len(related['1']) + len(related['2']) + has_page
     if page is not None:
         p = page
     elif len(related['1']) > 0:
         p = related['1'][0]
     elif len(related['2']) > 0:
         p = related['2'][0]
     else:
         return None
     if 'lines' in p:
         has_code = len([desc
                         for desc in p['lines']
                         if self._has_code(desc['text'])]) > 0
     else:
         self.log.info('No lines(maybe relatedPages): {}'.format(p['title']))
         details = sbapi.get(p['title'])
         has_code = len([desc
                         for desc in details['lines']
                         if self._has_code(desc['text'])]) > 0
     return {'description': self.summarized_desc(meme, p),
             'page_url': sbapi.get_view_url(p['title']),
             'title': p['title'],
             'has_code': has_code,
             'count': '{}'.format(count)}
 def get_tag_info(self, meme):
     sbapi = ScrapboxAPI(parent=self.nb_app)
     links = sbapi.get(meme)
     page_content = None
     related = {'1': [], '2': []}
     if links is not None:
         if links['persistent']:
             page_content = self.collect_content({'user': links['user']},
                                                 links)
         related['1'] = self.get_relates(links['relatedPages']['links1hop'])
         related['2'] = self.get_relates(links['relatedPages']['links2hop'])
     return self.summarize(meme, page_content, related), page_content, related
def test_get_from_public(requests_get):
    sbapi = ScrapboxAPI()
    sbapi.project_id = 'some_project'
    sbapi.get('some-meme')
    requests_get.assert_called_with('https://scrapbox.io/api/pages/'
                                    'some_project/some-meme')