Esempio n. 1
0
    def test_post_with_bad_content(self):
        postdata = {
            "content": "",
            "language": "en",
            "eventDate": "2016-3-1",
            "title": "test"
        }
        response = self.c.post(_URL, postdata)

        self.assertEquals(len(news.find()), 2)
Esempio n. 2
0
 def test_bad_targets2(self):
     postdata = {
         "content": "p>test</p>",
         "language": "en",
         "targets": " 12341234,12341234",
         "eventDate": "2016-3-1",
         "publishDate": "2016-3-1",
         "title": "test3"
     }
     response = self.c.post(_URL, postdata)
     self.assertEquals(len(news.find()), 2)
Esempio n. 3
0
    def test_post_with_bad_publishdate(self):
        postdata = {
            "content": "p>test</p>",
            "language": "en",
            "targets": [],
            "publishDate": "532452345",
            "eventDate": "2016-3-1",
            "title": "test3"
        }
        response = self.c.post(_URL, postdata)

        self.assertEquals(len(news.find()), 2)
Esempio n. 4
0
    def test_post(self):
        postdata = {
            "content": "p>test</p>",
            "language": "en",
            "targets": [],
            "publishDate": "2016-03-01T00:00:00+00:00",
            "eventDate": "2016-3-1",
            "title": "test3"
        }
        response = self.c.post(_URL, postdata)

        self.assertEquals(len(news.find()), 3)
Esempio n. 5
0
 def test_post_with_targets(self):
     I = individual.create("test", "test")
     I2 = individual.create("test", "test")
     targets = []
     targets.append(I.id)
     targets.append(I2.id)
     postdata = {
         "content": "p>test</p>",
         "language": "en",
         "targets": json.dumps(targets),
         "eventDate": "2016-3-1",
         "publishDate": "2016-3-1",
         "title": "test3"
     }
     response = self.c.post(_URL, postdata)
     self.assertEquals(len(news.find()), 3)
Esempio n. 6
0
def _list(request):
    """
    Controller for '/news/list'. GET returns json list of news
    """
    response = _RESPONSE_BASE.copy()
    response["news"] = {}
    for n in news.find():
        response["news"][n.id] = {
            "id": n.id,
            "title": n.title,
            "content": n.content,
            "language": n.language,
            "publishDate": n.publishDate,
            "eventDate": n.eventDate,
            "targets": list(n.targets),
        }
    return JsonResponse(response)
Esempio n. 7
0
 def test_delete(self):
     response = self.c.delete(_URL + self.A.id)
     self.assertEquals(len(news.find()), 1)