Ejemplo n.º 1
0
    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 update._fetched
        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 update._fetched
        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
Ejemplo n.º 2
0
    def test_contrib(self):
        thread_id = "dummy_thread_id"
        update_id = "dummy_update_id"
        update = LiveUpdate(self.reddit, thread_id, update_id)
        assert isinstance(update.contrib, LiveUpdateContribution)

        data = {"id": "dummy_update_id", "author": "dummy_author"}
        update = LiveUpdate(self.reddit, _data=data)
        assert isinstance(update.contrib, LiveUpdateContribution)
Ejemplo n.º 3
0
    def test_contrib(self):
        thread_id = 'dummy_thread_id'
        update_id = 'dummy_update_id'
        update = LiveUpdate(self.reddit, thread_id, update_id)
        assert isinstance(update.contrib, LiveUpdateContribution)

        data = {'id': 'dummy_update_id', 'author': 'dummy_author'}
        update = LiveUpdate(self.reddit, _data=data)
        assert isinstance(update.contrib, LiveUpdateContribution)
Ejemplo n.º 4
0
 def test_strike(self):
     self.reddit.read_only = False
     update = LiveUpdate(
         self.reddit, "xyu8kmjvfrww", "cb5fe532-dbee-11e6-9a91-0e6d74fabcc4"
     )
     with self.recorder.use_cassette("TestLiveUpdateContribution_strike"):
         update.contrib.strike()
Ejemplo n.º 5
0
 def test_remove(self, _):
     self.reddit.read_only = False
     update = LiveUpdate(
         self.reddit, "xyu8kmjvfrww", "5d556760-dbee-11e6-9f46-0e78de675452"
     )
     with self.recorder.use_cassette("TestLiveUpdateContribution_remove"):
         update.contrib.remove()
Ejemplo n.º 6
0
    def test_construct_failure(self):
        message = "Either `thread_id` and `update_id`, or `_data` must be provided."
        thread_id = "dummy_thread_id"
        update_id = "dummy_update_id"

        with pytest.raises(TypeError) as excinfo:
            LiveUpdate(self.reddit)
        assert str(excinfo.value) == message

        with pytest.raises(TypeError) as excinfo:
            LiveUpdate(self.reddit, thread_id=thread_id)
        assert str(excinfo.value) == message

        with pytest.raises(TypeError) as excinfo:
            LiveUpdate(self.reddit, update_id=update_id)
        assert str(excinfo.value) == message
Ejemplo n.º 7
0
 def test_attributes(self):
     update = LiveUpdate(self.reddit, "ukaeu1ik4sw5",
                         "7827987a-c998-11e4-a0b9-22000b6a88d2")
     with self.use_cassette():
         assert isinstance(update.author, Redditor)
         assert update.author == "umbrae"
         assert update.name == "LiveUpdate_7827987a-c998-11e4-a0b9-22000b6a88d2"
         assert update.body.startswith("Small change")
Ejemplo n.º 8
0
    def test_thread(self):
        thread_id = 'dummy_thread_id'
        update_id = 'dummy_update_id'

        update = LiveUpdate(self.reddit,
                            thread_id=thread_id,
                            update_id=update_id)
        assert isinstance(update.thread, LiveThread)
        assert update.thread.id == thread_id
Ejemplo n.º 9
0
 def test_attributes(self):
     update = LiveUpdate(self.reddit, 'ukaeu1ik4sw5',
                         '7827987a-c998-11e4-a0b9-22000b6a88d2')
     with self.recorder.use_cassette('TestLiveUpdate_test_attributes'):
         assert isinstance(update.author, Redditor)
         assert update.author == 'umbrae'
         assert update.name == (
             'LiveUpdate_7827987a-c998-11e4-a0b9-22000b6a88d2')
         assert update.body.startswith('Small change')
Ejemplo n.º 10
0
 def test_setattr(self):
     data = {'id': 'dummy_update_id', 'author': 'dummy_author'}
     update = LiveUpdate(self.reddit, _data=data)
     assert isinstance(update.author, Redditor)
Ejemplo n.º 11
0
 def test_contrib(self):
     thread_id = 'dummy_thread_id'
     update_id = 'dummy_update_id'
     update = LiveUpdate(self.reddit, thread_id, update_id)
     assert isinstance(update.contrib, LiveUpdateContribution)
Ejemplo n.º 12
0
 def test_setattr(self):
     data = {"id": "dummy_update_id", "author": "dummy_author"}
     update = LiveUpdate(self.reddit, _data=data)
     assert isinstance(update.author, Redditor)