Beispiel #1
0
 def test_update_request_all_recordings_changes(self):
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     rc = RecordingCollection(stream, req, stream.radius)
     req['session_id'] = self.session2.id
     rc.update_request(req)
     self.assertEquals([], rc.all_recordings)
 def test_update_request_all_recordings_changes(self):
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     rc = RecordingCollection(stream, req, stream.radius)
     req['session_id'] = self.session2.id
     rc.update_request(req)
     self.assertEquals([], rc.all_recordings)
 def test_update_request_far_recordings_changes(self):
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_near):
         rc = RecordingCollection(stream, req, stream.radius)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_far):
         rc.update_request(req)
         self.assertEquals([self.asset1, self.asset2], rc.far_recordings)
Beispiel #4
0
 def test_update_request_far_recordings_changes(self):
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_near):
         rc = RecordingCollection(stream, req, stream.radius)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_far):
         rc.update_request(req)
         self.assertEquals([self.asset1, self.asset2], rc.far_recordings)
    def test_correct_far_recordings(self):
        req = self.req1
        stream = RoundStream(self.session1.id, 'ogg', req)

        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_near):
            rc = RecordingCollection(stream, req, stream.radius)
            # Update the list of nearby recordings
            rc.update_request(req)

            self.assertEquals([], rc.far_recordings)  # everything close by

        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_far):
            rc2 = RecordingCollection(stream, req, stream.radius)  # all far
            self.assertEquals([self.asset1, self.asset2], rc2.far_recordings)
 def test_add_recording(self):
     """ add a specific asset id and it should show up in
     nearby_unplayed_recordings
     """
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_near):
         rc = RecordingCollection(stream, req, stream.radius, 'by_weight')
         # Update the list of nearby recordings
         rc.update_request(req)
         self.assertEquals([self.asset2, self.asset1],
                           rc.nearby_unplayed_recordings)
         rc.add_recording(self.asset2.id)
         self.assertEquals([self.asset2, self.asset2, self.asset1],
                           rc.nearby_unplayed_recordings)
Beispiel #7
0
    def test_correct_far_recordings(self):
        req = self.req1
        stream = RoundStream(self.session1.id, 'ogg', req)

        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_near):
            rc = RecordingCollection(stream, req, stream.radius)
            # Update the list of nearby recordings
            rc.update_request(req)

            self.assertEquals([], rc.far_recordings)  # everything close by

        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_far):
            rc2 = RecordingCollection(stream, req, stream.radius)  # all far
            self.assertEquals([self.asset1, self.asset2], rc2.far_recordings)
 def test_update_nearby_recordings_by_random(self):
     """ test that we don't get the same order more than 8 out of 
     10 tests.... not that scientific but probably reasonable
     """
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_near):
         rc = RecordingCollection(stream, req, stream.radius)
         order1 = self.asset1
         matched = 0
         for i in range(10):
             rc.update_nearby_recordings(req)
             nearby = rc.get_recording()
             if nearby == order1:
                 matched += 1
         self.assertTrue(matched <= 8)
         self.assertTrue(matched > 0)
Beispiel #9
0
 def test_update_nearby_recordings_by_random(self):
     """ test that we don't get the same order more than 8 out of 
     10 tests.... not that scientific but probably reasonable
     """
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_near):
         rc = RecordingCollection(stream, req, stream.radius)
         order1 = self.asset1
         matched = 0
         for i in range(10):
             rc.update_nearby_recordings(req)
             nearby = rc.get_recording()
             if nearby == order1:
                 matched += 1
         self.assertTrue(matched <= 8)
         self.assertTrue(matched > 0)
Beispiel #10
0
 def test_add_recording(self):
     """ add a specific asset id and it should show up in
     nearby_unplayed_recordings
     """
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     with patch.object(gpsmixer, 'distance_in_meters',
                       mock_distance_in_meters_near):
         rc = RecordingCollection(stream, req, stream.radius, 'by_weight')
         # Update the list of nearby recordings
         rc.update_request(req)
         self.assertEquals([self.asset2, self.asset1],
                           rc.nearby_unplayed_recordings)
         rc.add_recording(self.asset2.id)
         self.assertEquals([self.asset2, self.asset2, self.asset1],
                           rc.nearby_unplayed_recordings)
Beispiel #11
0
    def test_get_recording_until_none_repeatmode_stop(self):
        """ test that we get the next unplayed nearby recording, until there
        are none left.  project in stop repeatmode should then not 
        return any recordings.
        """
        req = self.req1
        req["project_id"] = self.project1.id  # required by get_recording
        stream = RoundStream(self.session1.id, 'ogg', req)
        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_near):
            rc = RecordingCollection(stream, req, stream.radius, 'by_weight')
            # Update the list of nearby recordings
            rc.update_request(req)

            next_rec = rc.get_recording()
            self.assertEquals(self.asset2, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(self.asset1, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(None, next_rec)
Beispiel #12
0
    def test_get_recording_until_none_repeatmode_continuous(self):
        """ test that we get the next unplayed nearby recording, until there
        are none left.  project in continuous repeatmode should then the
        first played recording 
        """
        self.project1.repeat_mode.mode = "continuous"
        self.project1.repeat_mode.save()
        req = self.req1
        stream = RoundStream(self.session1.id, 'ogg', req)
        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_near):
            rc = RecordingCollection(stream, req, stream.radius, 'by_weight')
            # Update the list of nearby recordings
            rc.update_request(req)

            next_rec = rc.get_recording()
            self.assertEquals(self.asset2, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(self.asset1, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(self.asset2, next_rec)
    def test_get_recording_until_none_repeatmode_stop(self):
        """ test that we get the next unplayed nearby recording, until there
        are none left.  project in stop repeatmode should then not 
        return any recordings.
        """
        req = self.req1
        req["project_id"] = self.project1.id  # required by get_recording
        stream = RoundStream(self.session1.id, 'ogg', req)
        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_near):
            rc = RecordingCollection(stream, req, stream.radius, 'by_weight')
            # Update the list of nearby recordings
            rc.update_request(req)

            next_rec = rc.get_recording()
            self.assertEquals(self.asset2, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(self.asset1, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(None, next_rec)
    def test_get_recording_until_none_repeatmode_continuous(self):
        """ test that we get the next unplayed nearby recording, until there
        are none left.  project in continuous repeatmode should then the
        first played recording 
        """
        self.project1.repeat_mode.mode = "continuous"
        self.project1.repeat_mode.save()
        req = self.req1
        stream = RoundStream(self.session1.id, 'ogg', req)
        with patch.object(gpsmixer, 'distance_in_meters',
                          mock_distance_in_meters_near):
            rc = RecordingCollection(stream, req, stream.radius, 'by_weight')
            # Update the list of nearby recordings
            rc.update_request(req)

            next_rec = rc.get_recording()
            self.assertEquals(self.asset2, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(self.asset1, next_rec)
            next_rec = rc.get_recording()
            self.assertEquals(self.asset2, next_rec)
Beispiel #15
0
 def test_correct_all_recordings(self):
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     rc = RecordingCollection(stream, req, stream.radius)
     self.assertEquals([self.asset1, self.asset2], rc.all_recordings)
Beispiel #16
0
 def test_instantiate_recording_collection(self):
     req = self.req1
     stream = RoundStream(self.session1.id, 'ogg', req)
     rc = RecordingCollection(stream, req, stream.radius)
     self.assertEquals(rc.__class__.__name__, 'RecordingCollection')
     self.assertEquals('random', rc.ordering)