Exemplo n.º 1
0
def create_news_record(news_model_data):
    try:
        news = News(**news_model_data)
        news._id = str(uuid4().hex)
        news.save()
    except Exception as e:
        raise e
Exemplo n.º 2
0
def create_news_record(news_model_data):
    try:
        from uuid import uuid4
        news = News(**news_model_data)
        news._id = unicode(uuid4().hex)
        news.save()
    except Exception, e:
        raise e
Exemplo n.º 3
0
    def test_create_only_required_fields_success(self):
        # given
        _id = self.generate_uuid_32_string()
        news_data = {
            '_id': _id,
            'url': 'http://blog.scielo.org',
            'image_url': 'http://blog.scielo.org/sample.png',
            'publication_date': datetime.now(),
            'title': 'foo bar',
            'description': 'lorem ipsum dolor sit ahmet',
            'language': 'en',
            'is_public': True
        }
        # when
        news_doc = News(**news_data)
        news_doc.save()

        # then
        news_count = News.objects.all().count()
        self.assertEqual(_id, news_doc._id)
        self.assertEqual(1, news_count)