From 171748828bceebe7e41f2f92806a4146fbf13c4e Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Sun, 10 Mar 2024 18:22:13 -0400 Subject: [PATCH] Add forum_threads unit test. --- test/data/forum_threads.html | 485 +++++++++++++++++++++++++++++++++++ test/test_forum_threads.py | 41 +++ 2 files changed, 526 insertions(+) create mode 100644 test/data/forum_threads.html create mode 100644 test/test_forum_threads.py diff --git a/test/data/forum_threads.html b/test/data/forum_threads.html new file mode 100644 index 0000000..2523b97 --- /dev/null +++ b/test/data/forum_threads.html @@ -0,0 +1,485 @@ +
+
+ Forum + » + SCP Universe / + Foundation Universe +
+ +
+
+ Number of threads: 2845
+ Number of posts: 27892
+ rss icon + RSS: New threads | New posts + +
+ Discussion of things relating to both the SCP objects and the "universe" of the Foundation as a whole. +
+ +
+ Order by:
Last post date
Thread starting date +
+ +
+ Create a new thread +
+ +
page 1 of 143123...142143next »
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Thread name + Started + Posts + Recent post
+ +
+ What the title says. If you can remember a brief description or an idea of what you're looking for, get help searching for that page here. +
+
+ by: ZynZyn
+ 14 Jan 2015 05:55 +
+ 1123 + + by apiphaneeapiphanee
+ 09 Mar 2024 19:45 + Jump! +
+ +
+ ... as of 4-10-19 +
+
+ by: PetrogradPetrograd
+ 13 Apr 2019 01:54 +
+ 18 + + by TheRedRightHandTheRedRightHand
+ 05 Jan 2024 16:40 + Jump! +
+
+ Sticky: + The Leak
+
+
+ In-universe spoilers/info leaks +
+
+ by: Dr GearsDr Gears
+ 09 Sep 2012 15:05 +
+ 443 + + by UraniumEmpireUraniumEmpire
+ 25 Aug 2023 23:28 + Jump! +
+ +
+ The SCP-231 phenomenon created 6 monsters, where are they now? (NSFW and disturbing sexual themes) +
+
+ by: Dr BlackboxDr Blackbox
+ 25 Nov 2018 18:18 +
+ 29 + + by FrankEntropyFrankEntropy
+ 10 Mar 2024 08:33 + Jump! +
+ +
+ Overall the article is very lackluster and unoriginal. I think it could use a rewrite. +
+
+ by: Jacob1700Jacob1700
+ 21 Dec 2023 18:17 +
+ 12 + + by Dr DirenniDr Direnni
+ 08 Mar 2024 19:10 + Jump! +
+ +
+ +
+
+ by: scythe the dangerscythe the danger
+ 26 Feb 2024 01:17 +
+ 5 + + by ReillyinReillyin
+ 08 Mar 2024 12:10 + Jump! +
+ +
+ The stranger the better! +
+
+ by: NatVoltaicNatVoltaic
+ 14 Aug 2016 02:26 +
+ 469 + + by ReillyinReillyin
+ 08 Mar 2024 12:08 + Jump! +
+ +
+ Can the GOC and the UN leave eachother? +
+
+ by: ReillyinReillyin
+ 08 Mar 2024 12:03 +
+ 1 + +   +
+ +
+ What is and isn’t anomalous? S E R I O U S - Q U E S T I O N +
+
+ by: Rb-Dn2247Rb-Dn2247
+ 25 Feb 2024 21:18 +
+ 8 + + by ReillyinReillyin
+ 08 Mar 2024 11:55 + Jump! +
+ +
+ Do other fictional organisations tasked to handle and investigate anomalies bleed over into the SCP universe, or do any notable analogues of fictional characters from such works appear? Are there any such references? +
+
+ by: SelvedgeSelvedge
+ 26 Feb 2024 22:16 +
+ 1 + +   +
+ +
+ Critique of the Fire Suppression Department. +
+
+ by: Chariton101Chariton101
+ 24 Jan 2024 12:55 +
+ 7 + + by PetrogradPetrograd
+ 24 Feb 2024 13:03 + Jump! +
+ +
+ My SCP is an inanimate object. What do I say for its containment procedures? +
+
+ by: NameIsIrrelevant NameIsIrrelevant
+ 20 Feb 2024 23:55 +
+ 3 + + by aismallardaismallard
+ 21 Feb 2024 04:15 + Jump! +
+ +
+ Hey new here, I just had a question as to how the foundation is perceived by the world +
+
+ by: UnibrowBoyUnibrowBoy
+ 23 Feb 2023 07:07 +
+ 3 + + by YardBirdMeYardBirdMe
+ 18 Feb 2024 07:54 + Jump! +
+ +
+ What are the requirements for a group to join it? +
+
+ by: TheWinterGuyTheWinterGuy
+ 23 Dec 2023 09:40 +
+ 2 + + by YardBirdMeYardBirdMe
+ 18 Feb 2024 07:39 + Jump! +
+ +
+ Hypothetical Question: Every Series I SCP is in the ring. Who's coming out as the victor? (overpowered SCP's don't count. I'll leave you to decide if an SCP is overpowered or not. Neither do any SCP-000 proposals.) +
+
+ by: fraypeltedfraypelted
+ 19 Nov 2023 02:53 +
+ 14 + + by Rb-Dn2247Rb-Dn2247
+ 17 Feb 2024 20:49 + Jump! +
+ +
+ +
+
+ by: Timelord01Timelord01
+ 15 Feb 2024 01:04 +
+ 3 + + by Rb-Dn2247Rb-Dn2247
+ 17 Feb 2024 20:44 + Jump! +
+ +
+ Wondering about simple dimensional economics +
+
+ by: GrecoEgyptianGrecoEgyptian
+ 18 Jan 2024 01:58 +
+ 6 + + by RancoriousRancorious
+ 14 Feb 2024 05:59 + Jump! +
+ +
+ +
+
+ by: TaaargetTaaarget
+ 12 Feb 2024 19:17 +
+ 3 + + by RancoriousRancorious
+ 14 Feb 2024 05:42 + Jump! +
+ +
+ +
+
+ by: darkedalbdarkedalb
+ 11 Feb 2024 03:20 +
+ 3 + + by darkedalbdarkedalb
+ 11 Feb 2024 04:04 + Jump! +
+ +
+ Asking about what happens when two individually safe-to-perceive components make up a cognitohazard, but only together. +
+
+ by: (account deleted)
+ 26 Jan 2024 22:27 +
+ 3 + + by (account deleted)
+ 27 Jan 2024 10:13 + Jump! +
+ +
page 1 of 143123...142143next »
+ +
\ No newline at end of file diff --git a/test/test_forum_threads.py b/test/test_forum_threads.py new file mode 100644 index 0000000..a79f6c6 --- /dev/null +++ b/test/test_forum_threads.py @@ -0,0 +1,41 @@ +import unittest +from unittest.mock import patch + +import requests + +from yellowstone.request import forum_threads +from yellowstone.request.forum_threads import ForumThreadData + +from .helpers import FakeResponse, make_wikidot + + +class TestForumThreads(unittest.TestCase): + def setUp(self): + self.wikidot = make_wikidot() + + def test_forum_threads(self): + http_response = FakeResponse.ajax_from_file("forum_threads") + with patch.object(requests, "post", return_value=http_response) as mock: + models = forum_threads.get( + "scp-wiki", + category_id=50742, + offset=1, + wikidot=self.wikidot, + ) + mock.assert_called_once() + + self.assertEqual(len(models), 20) + self.assertIsInstance(models[0], ForumThreadData) + + self.assertEqual(models[0].id, 1082671) + self.assertIn("Trying to find an SCP or Tale", models[0].title) + self.assertIn("What the title says", models[0].description) + self.assertTrue(models[0].sticky) + self.assertEqual(models[0].created_by.name, "Zyn") + self.assertEqual(models[0].post_count, 1123) + + self.assertEqual(models[2].id, 561911) + self.assertEqual(models[2].title, "The Leak") + self.assertEqual(models[2].description, "In-universe spoilers/info leaks") + self.assertTrue(models[2].sticky) + self.assertEqual(models[2].created_by.name, "Dr Gears")