예제 #1
0
        public void ArchiveFailedTweets_TweetArchived()
        {
            ClearModerationQueues();

            var paramList = new DnaTestURLRequest.ParamList();

            // Post three tweets, and collect the param list for the ModeratePost call later
            // It checked that only failed tweets get archived to the "Deleted" tables

            // This one will fail moderation
            PostTweet(CreateTestTweet(64645735745376, "I, Partridge", "76767676", "Alan Partridge", "Ahah!"), ModerationStatus.ForumStatus.PreMod);
            AddLatestPreModPostingToParamList(paramList, ModerationItemStatus.Failed, BBC.Dna.Api.PostStyle.Style.tweet);

            // This one will pass moderation
            PostTweet(CreateTestTweet(64645735745377, "chat suicide", "76767676", "Alan Partridge", "Ahah!"), ModerationStatus.ForumStatus.PreMod);
            AddLatestPreModPostingToParamList(paramList, ModerationItemStatus.Passed, BBC.Dna.Api.PostStyle.Style.tweet);

            // This one will fail moderation, but the post style is not a tweet
            PostTweet(CreateTestTweet(64645735745378, "dormant volcano", "76767676", "Alan Partridge", "Ahah!"), ModerationStatus.ForumStatus.PreMod);
            AddLatestPreModPostingToParamList(paramList, ModerationItemStatus.Failed, BBC.Dna.Api.PostStyle.Style.plaintext);

            // Moderate these posts
            var request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserEditor();
            request.RequestPageWithParamList("ModeratePosts", paramList);

            using (IDnaDataReader reader = _context.CreateDnaDataReader(""))
            {

                reader.ExecuteDEBUGONLY(@"
                    select * 
                        from PreModPostingsDeleted pmpd
                        join PreModPostingsTweetInfoDeleted pmptid on pmptid.modid=pmpd.modid
                        join ThreadModDeleted tmd on tmd.modid = pmptid.modid
                        where pmpd.reason='A' and pmptid.reason='A' and tmd.reason='A'");
                Assert.IsTrue(reader.Read());
                Assert.AreEqual(64645735745376, reader.GetInt64("tweetid"));
                Assert.AreEqual("I, Partridge", reader.GetString("body"));
                Assert.IsFalse(reader.Read(), "Only expecting one row of archived deleted posts");

                // Check the last two posts are the other two moderated posts
                reader.ExecuteDEBUGONLY(@"
                    select top 2 * 
                        from ThreadEntries te
                        join ThreadEntriesTweetInfo teti on teti.ThreadEntryId=te.EntryId
                        order by te.entryid desc");

                Assert.IsTrue(reader.Read());
                Assert.AreEqual(64645735745378, reader.GetInt64("tweetid"));
                Assert.AreEqual("dormant volcano", reader.GetString("text"));
                Assert.AreEqual(1, reader.GetInt32("Hidden"), "This post failed moderation so should be hidden");

                Assert.IsTrue(reader.Read());
                Assert.AreEqual(64645735745377, reader.GetInt64("tweetid"));
                Assert.AreEqual("chat suicide", reader.GetString("text"));
                Assert.IsFalse(reader.GetNullableInt32("Hidden").HasValue, "The hidden flag should be NULL, i.e. not hidded");
            }

        }