Example #1
0
 def test_edit_invalid(self, _):
     self.reddit.read_only = False
     self.reddit.validate_on_submit = True
     with self.recorder.use_cassette("TestSubmission.test_edit_invalid"):
         submission = Submission(self.reddit, "eippcc")
         with pytest.raises(RedditAPIException):
             submission.edit("rewtwert")
Example #2
0
 def test_edit(self, _):
     self.reddit.read_only = False
     with self.recorder.use_cassette(
             'TestSubmission.test_edit'):
         submission = Submission(self.reddit, '4b1tfm')
         submission.edit('New text')
         assert submission.selftext == 'New text'
Example #3
0
 def test_edit(self, _):
     self.reddit.read_only = False
     with self.recorder.use_cassette(
             'TestSubmission.test_edit'):
         submission = Submission(self.reddit, '4b1tfm')
         submission.edit('New text')
         assert submission.selftext == 'New text'
def edit_submission(text, submission_url):
    if submission_url == "":
        log("EDIT: Submission url is empty")
        return
    submission = Submission(reddit_auth, url=submission_url)
    submission.edit(text)
    log("Submission edited")
Example #5
0
 def update_existing(self, active_games):
     # For all active/recent games
     # Format thread
     for game in active_games:
         stored_game = self.games[game.id]
         for thread_type in ('gamethread', 'post_gamethread'):
             if thread_type in stored_game.threads:
                 # Update body
                 thread_id = stored_game.threads[thread_type]
                 thread = Submission(self.r, id=thread_id)
                 title, body = self.renderer.render_game(game,
                                                         thread_type,
                                                         thread=thread)
                 if body is not None and body != thread.selftext:
                     print("Update %s (/r/%s, %s)" %
                           (title, self.sub.display_name, thread_id))
                     print(diff_strings(thread.selftext, body))
                     thread.edit(body)
Example #6
0
 def test_edit(self, _):
     self.reddit.read_only = False
     with self.recorder.use_cassette("TestSubmission.test_edit"):
         submission = Submission(self.reddit, "4b1tfm")
         submission.edit("New text")
         assert submission.selftext == "New text"
Example #7
0
                output = [name, level.scores_compactStr()]
                writer.writerow(output)

    # prepare output
    outputLevels = OrderedDict()
    for name, level in levels.items():
        out_sc = OutputScores(level.level_type)
        if level.scores is not None:
            for score in level.scores:
                out_sc.add(score)
            out_sc.frontierStr = level.scores_simpleStr()
        outputLevels[name] = out_sc

    table = levelstable(outputLevels)
    if args.print:
        print(table)

    if args.post:
        # build body
        body = ''
        with open('prefix.md') as prefixfile:
            body += prefixfile.read()
        body += table
        body += f'\nTable built on {datetime.datetime.utcfromtimestamp(current_timestamp)} UTC\n'
        with open('suffix.md') as suffixfile:
            body += suffixfile.read()

        # Post to reddit
        post = Submission(reddit, id='884gmc')
        post.edit(body)
Example #8
0
 def test_edit(self, _):
     self.reddit.read_only = False
     with self.recorder.use_cassette("TestSubmission.test_edit"):
         submission = Submission(self.reddit, "4b1tfm")
         submission.edit("New text")
         assert submission.selftext == "New text"