示例#1
0
 def test_database_paths(self):
     share1 = testobjects.make_share('TestShare')
     self.assertEquals(share1.db_path,
                       os.path.join(self.sandbox_support_directory,
                                    'sharing-db-0'))
     share2 = testobjects.make_share('TestShare2')
     self.assertEquals(share2.db_path,
                       os.path.join(self.sandbox_support_directory,
                                    'sharing-db-1'))
示例#2
0
 def test_stop_tracking_twice(self):
     # Check that that calling stop_tracking() twice in a row
     share = testobjects.make_share()
     share.start_tracking()
     share.stop_tracking()
     self.assertEquals(share.tracker, None)
     # second call shouldn't cause an error
     share.stop_tracking()
示例#3
0
 def test_start_tracking_twice(self):
     # Check that that calling start_tracking() twice in a row
     share = testobjects.make_share()
     share.start_tracking()
     first_tracker = share.tracker
     share.start_tracking()
     # second call should keep the same tracker
     self.assertEquals(share.tracker, first_tracker)
示例#4
0
 def test_create_and_destroy(self):
     share = testobjects.make_share()
     self.assertNotEquals(share.db_path, None)
     self.assertNotEquals(share.db_info, None)
     old_path = share.db_path
     share.destroy()
     self.assertEquals(share.db_path, None)
     self.assertEquals(share.db_info, None)
     if os.path.exists(old_path):
         raise AssertionError("Calling Share.destroy() "
                              "didn't delete database")
示例#5
0
 def test_database_create_deletes_old_files(self):
     # test that if there's a file leftover from a previous miro run, we
     # delete it and then re-use it
     old_path = os.path.join(self.sandbox_support_directory, 'sharing-db-0')
     with open(old_path, 'wb') as f:
         f.write("old data")
     share = testobjects.make_share()
     self.assertEquals(share.db_path, old_path)
     # check that we opened a sqlite database on that path and overwrote
     # the old data
     if open(old_path).read() == 'old data':
         raise AssertionError("Didn't overwrite old path")
示例#6
0
 def setup_share(self):
     # make a share and that uses our mock client
     self.patch_function('miro.libdaap.make_daap_client',
                         lambda *args, **kwargs: self.client)
     # Make sure the SharingItemTrackerImpl doesn't actually create a
     # thread.  We want to manually call its methods and have them run in
     # the in the main thread.
     self.patch_for_test('miro.sharing.SharingItemTrackerImpl.start_thread')
     self.share = testobjects.make_share()
     self.share_info = messages.SharingInfo(self.share)
     self.share.set_info(self.share_info)
     self.share.start_tracking()
     self.run_client_connect()
示例#7
0
 def test_database_create_deletes_old_files(self):
     # test that if there's a file leftover from a previous miro run, we
     # delete it and then re-use it
     old_path = os.path.join(self.sandbox_support_directory,
                             'sharing-db-0')
     with open(old_path, 'wb') as f:
         f.write("old data")
     share = testobjects.make_share()
     self.assertEquals(share.db_path, old_path)
     # check that we opened a sqlite database on that path and overwrote
     # the old data
     if open(old_path).read() == 'old data':
         raise AssertionError("Didn't overwrite old path")
示例#8
0
 def setup_share(self):
     # make a share and that uses our mock client
     self.patch_for_test('miro.libdaap.make_daap_client',
                         self.client.returnself)
     # Make sure the SharingItemTrackerImpl doesn't actually create a
     # thread.  We want to manually call its methods and have them run in
     # the in the main thread.
     self.patch_for_test('miro.sharing.SharingItemTrackerImpl.start_thread')
     self.share = testobjects.make_share()
     self.share_info = messages.SharingInfo(self.share)
     self.share.set_info(self.share_info)
     self.share.start_tracking()
     self.run_client_connect()
示例#9
0
 def test_start_tracking(self):
     share = testobjects.make_share()
     self.assertEquals(share.tracker, None)
     # Calling start_tracking should create a SharingItemTrackerImpl
     share.start_tracking()
     self.assertNotEquals(share.tracker, None)
     tracker = share.tracker
     share.stop_tracking()
     self.assertEquals(share.tracker, None)
     # check that we call client_disconnect()
     self.assertEquals(tracker.client_disconnect.call_count, 1)
     # Calling start_tracking() again should re-create the tracker
     share.start_tracking()
     self.assertNotEquals(share.tracker, None)
示例#10
0
 def setUp(self):
     EventLoopTest.setUp(self)
     self.share = testobjects.make_share()
     self.playlist_item_map = mappings.SharingItemPlaylistMap(
         self.share.db_info.db.connection)
     # Replace threading.Thread() with a mock object so that
     # SharingItemTrackerImpl objects don't create real theads.
     self.patch_for_test('threading.Thread')
     # Replace update_started() and update_finished() with mock objects.
     # We want to ignore the TabsChanged messages that they send out.
     self.patch_for_test('miro.sharing.Share.update_started')
     self.patch_for_test('miro.sharing.Share.update_finished')
     # also use a Mock object for the daap client
     self.client = testobjects.MockDAAPClient()
     self.patch_function('miro.libdaap.make_daap_client',
                         lambda *args, **kwargs: self.client)
     self.MockTabsChanged = self.patch_for_test('miro.messages.TabsChanged')
示例#11
0
 def setUp(self):
     EventLoopTest.setUp(self)
     self.share = testobjects.make_share()
     self.playlist_item_map = mappings.SharingItemPlaylistMap(
         self.share.db_info.db.connection)
     # Replace threading.Thread() with a mock object so that
     # SharingItemTrackerImpl objects don't create real theads.
     self.patch_for_test('threading.Thread')
     # Replace update_started() and update_finished() with mock objects.
     # We want to ignore the TabsChanged messages that they send out.
     self.patch_for_test('miro.sharing.Share.update_started')
     self.patch_for_test('miro.sharing.Share.update_finished')
     # also use a Mock object for the daap client
     self.client = testobjects.MockDAAPClient()
     self.patch_for_test('miro.libdaap.make_daap_client',
                         self.client.returnself)
     self.MockTabsChanged = self.patch_for_test(
         'miro.messages.TabsChanged')