예제 #1
0
 def test_most_recent_article_version_unpublished(self):
     self.unpublish(self.msid2, version=3)
     self.assertEqual(
         models.ArticleVersion.objects.filter(
             article__manuscript_id=self.msid2).exclude(
                 datetime_published=None).count(), 2)
     av = logic.most_recent_article_version(
         self.msid2)  # , only_published=False)
     self.assertEqual(av.version, 2)
예제 #2
0
    def test_related_articles_expected_data(self):
        # create a relationship between 1 and 2
        relation_logic._relate_using_msids([(self.msid1, [self.msid2])])

        # no auth
        expected = [
            logic.article_snippet_json(
                logic.most_recent_article_version(self.msid2))
        ]
        resp = self.c.get(
            reverse('v2:article-relations', kwargs={'id': self.msid1}))
        data = utils.json_loads(resp.content)
        self.assertEqual(expected, data)

        # auth
        expected = [
            logic.article_snippet_json(
                logic.most_recent_article_version(self.msid2,
                                                  only_published=False))
        ]
        resp = self.ac.get(
            reverse('v2:article-relations', kwargs={'id': self.msid1}))
        data = utils.json_loads(resp.content)
        self.assertEqual(expected, data)
예제 #3
0
    def test_logic_doesnt_mangle_unicode(self):
        "the api logic doesn't alter unicode values"
        ajson = json.load(open(self.ajson_fixture1, 'r'))
        ajson_ingestor.ingest_publish(ajson)

        expected = ajson['snippet']['authors'][1]['name']['preferred']

        # /articles/{id}
        given = logic.most_recent_article_version(
            self.msid).article_json_v1['authors'][1]['name']['preferred']
        self.assertEqual(expected, given)

        # /articles/{id}/versions/{version}
        given = logic.article_version(
            self.msid,
            self.version).article_json_v1['authors'][1]['name']['preferred']
        self.assertEqual(expected, given)
예제 #4
0
 def test_most_recent_article_version_unpublished(self):
     self.unpublish(self.msid2, version=3)
     self.assertEqual(models.ArticleVersion.objects.filter(article__manuscript_id=self.msid2).exclude(datetime_published=None).count(), 2)
     av = logic.most_recent_article_version(self.msid2)  # , only_published=False)
     self.assertEqual(av.version, 2)
예제 #5
0
 def test_most_recent_article_version(self):
     "an article with three versions returns the highest version of the three"
     av = logic.most_recent_article_version(self.msid2)
     expected_version = 3
     self.assertEqual(av.version, expected_version)
예제 #6
0
 def test_most_recent_article_version(self):
     "an article with three versions returns the highest version of the three"
     av = logic.most_recent_article_version(self.msid2)
     expected_version = 3
     self.assertEqual(av.version, expected_version)