Completed
Pull Request — master (#341)
by
unknown
01:58
created

ArticleGet._validate_article()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 9
rs 9.6667
1
import json
2
3
from lib.actions import BaseAction
4
5
6
class ArticleGet(BaseAction):
7
    def run(self, title, body, topic=None, status=0):
8
        if topic:
9
            topic = self._convert_slug(topic)
10
            path = '/topics/%s/articles' % topic
11
        else:
12
            path = '/articles'
13
        payload = self._create_payload(title=title, body=body, status=status)
14
        response = self._api_post(path, data=payload)
15
        article = response['articles']
16
17
        return article
18
19
    def _validate_article(self, title, body, status=0):
20
        payload = {
21
            'article': {
22
                'title': title,
23
                'body': body,
24
                'status': status
25
            }
26
        }
27
        return json.dumps(payload)
28