Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_update__full_settings(self, _):
new_settings = {
"title": "new title 2",
"description": "## new description 2",
"nsfw": True,
"resources": "## new resources 2",
}
self.reddit.read_only = False
thread = LiveThread(self.reddit, "xyu8kmjvfrww")
with self.recorder.use_cassette(
"TestLiveThreadContribution.test_update__full_settings"
):
thread.contrib.update(**new_settings)
assert thread.title == new_settings["title"]
assert thread.description == new_settings["description"]
assert thread.nsfw == new_settings["nsfw"]
assert thread.resources == new_settings["resources"]
def test_equality(self):
thread1 = LiveThread(self.reddit, id="dummy1")
thread2 = LiveThread(self.reddit, id="Dummy1")
thread3 = LiveThread(self.reddit, id="dummy3")
assert thread1 == thread1
assert thread2 == thread2
assert thread3 == thread3
assert thread1 != thread2 # live thread ID in a URL is case sensitive
assert thread2 != thread3
assert thread1 != thread3
assert "dummy1" == thread1
assert thread2 != "dummy1"
assert thread2 == "Dummy1"
def test_invite__empty_list(self):
self.reddit.read_only = False
thread = LiveThread(self.reddit, "xyu8kmjvfrww")
with self.recorder.use_cassette(
"TestLiveContributorRelationship_test_invite__empty_list"
):
thread.contributor.invite("nmtake", [])
def test_update_invite__limited(self):
self.reddit.read_only = False
thread = LiveThread(self.reddit, "ydwwxneu7vsa")
with self.recorder.use_cassette(
"TestLiveContributorRelationship_test_update_invite__limited"
):
thread.contributor.update_invite("nmtake", ["manage", "edit"])
def test_construct_success(self):
thread_id = "dummy_thread_id"
update_id = "dummy_update_id"
data = {"id": update_id}
update = LiveUpdate(
self.reddit, thread_id=thread_id, update_id=update_id
)
assert isinstance(update, LiveUpdate)
assert update.id == update_id
assert isinstance(update.thread, LiveThread)
assert update.thread.id == thread_id
update = LiveUpdate(self.reddit, thread_id, update_id)
assert isinstance(update, LiveUpdate)
assert update.id == update_id
assert isinstance(update.thread, LiveThread)
assert update.thread.id == thread_id
update = LiveUpdate(self.reddit, _data=data)
assert isinstance(update, LiveUpdate)
assert update.id == update_id
assert update._fetched
def test_remove__fullname(self):
self.reddit.read_only = False
thread = LiveThread(self.reddit, "xyu8kmjvfrww")
with self.recorder.use_cassette(
"TestLiveContributorRelationship_test_remove__fullname"
):
thread.contributor.remove("t2_ll32z")
def test_hash(self):
thread1 = LiveThread(self.reddit, id="dummy1")
thread2 = LiveThread(self.reddit, id="Dummy1")
thread3 = LiveThread(self.reddit, id="dummy3")
assert hash(thread1) == hash(thread1)
assert hash(thread2) == hash(thread2)
assert hash(thread3) == hash(thread3)
assert hash(thread1) != hash(thread2)
assert hash(thread2) != hash(thread3)
assert hash(thread1) != hash(thread3)
def test_construct_success(self):
thread_id = "ukaeu1ik4sw5"
data = {"id": thread_id}
thread = LiveThread(self.reddit, thread_id)
assert isinstance(thread, LiveThread)
assert thread.id == thread_id
thread = LiveThread(self.reddit, _data=data)
assert isinstance(thread, LiveThread)
assert thread.id == thread_id
def test_add(self):
self.reddit.read_only = False
thread = LiveThread(self.reddit, "xyu8kmjvfrww")
with self.recorder.use_cassette("TestLiveThreadContribution_add"):
thread.contrib.add("* `LiveThreadContribution.add() test`")
def test_updates(self, _):
thread = LiveThread(self.reddit, "ukaeu1ik4sw5")
with self.recorder.use_cassette("TestLiveThread_test_updates"):
for update in thread.updates(limit=None):
assert update.thread == thread
assert update.body.startswith("Small change:")