Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(7)  |  Derive(0)  |  Import(0)
Handle a new update.

Fetches new data from the client, then compares it to the previous
lookup.

Returns:
    (bool, new_data): whether changes occurred, and the new value.

src/m/p/mpdlcd-0.4.0/tests/test_mpdhooks.py   mpdlcd(Download)
        # Default is 'no song'
        client = self.FakeClient(current_song={})
        changed, new = hook.handle(client)
        self.assertFalse(changed)
        self.assertIsNone(new)
 
        # New song loaded
        new_song = FakeSong()
        client2 = self.FakeClient(current_song=new_song)
        changed2, new2 = hook.handle(client2)
        other_song = FakeSong(id=13)
        client3 = self.FakeClient(current_song=other_song)
        changed3, new3 = hook.handle(client3)
        self.assertTrue(changed3)
        self.assertEqual(other_song, new3)
 
        # Another field changes
        client4 = self.FakeClient(current_song=other_song, state='play')
        changed4, new4 = hook.handle(client4)
        other_song_full = FakeSong(id=13, title="other", artist="someone")
        client5 = self.FakeClient(current_song=other_song_full)
        changed5, new5 = hook.handle(client5, ('title', 'artist'))
        self.assertTrue(changed5)
        self.assertEqual(other_song_full, new5)