Beispiel #1
0
 def test_change_track_fails_when_track_not_found(self):
     # Arrange & Act
     result = api_track.change_track('bogus track')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     error = 'Track not found'  # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #2
0
 def test_change_track_fails_when_track_not_found(self):
     # Arrange & Act
     result = api_track.change_track('bogus track')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     error = 'Track not found' # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #3
0
 def test_change_track_fails_when_no_new_data_entered(self):
     # Arrange
     track = Track.objects.create(name='bogus track', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track('bogus track')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     error = 'At least one new track detail is required' # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #4
0
 def test_change_track_fails_when_new_timeout_is_invalid(self):
     # Arrange
     track = Track.objects.create(name='bogus track', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track(track_name='bogus track',
         new_lap_timeout='bogus')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     self.assertEqual('ValueError', result.data)
Beispiel #5
0
 def test_change_track_fails_when_no_new_data_entered(self):
     # Arrange
     track = Track.objects.create(name='bogus track',
                                  distance=50,
                                  timeout=100,
                                  unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track('bogus track')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     error = 'At least one new track detail is required'  # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #6
0
 def test_change_track_fails_when_new_timeout_is_invalid(self):
     # Arrange
     track = Track.objects.create(name='bogus track',
                                  distance=50,
                                  timeout=100,
                                  unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track(track_name='bogus track',
                                     new_lap_timeout='bogus')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     self.assertEqual('ValueError', result.data)
Beispiel #7
0
 def test_change_track_fails_when_new_track_found(self):
     # Arrange
     track = Track.objects.create(name='bogus track 1', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     track = Track.objects.create(name='bogus track 2', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track('bogus track 1', 'bogus track 2')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     error = 'Track already exists' # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #8
0
 def test_change_track_passes(self):
     # Arrange
     track = Track.objects.create(name='bogus track', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track(track_name='bogus track',
         new_track_name='bogus track 2', new_track_distance=51,
         new_lap_timeout=101, new_unit_of_measurement=settings.IMPERIAL)
     # Assert
     self.assertTrue(result.ok)
     self.assertEqual('change_track', result.call)
     track = Track.objects.get(name='bogus track 2')
     self.assertEqual(track, result.data)
     self.assertEqual(51, track.distance)
     self.assertEqual(101, track.timeout)
     self.assertEqual(settings.IMPERIAL, track.unit_of_measurement)
Beispiel #9
0
 def test_change_track_fails_when_new_track_found(self):
     # Arrange
     track = Track.objects.create(name='bogus track 1',
                                  distance=50,
                                  timeout=100,
                                  unit_of_measurement=settings.METRIC)
     track = Track.objects.create(name='bogus track 2',
                                  distance=50,
                                  timeout=100,
                                  unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track('bogus track 1', 'bogus track 2')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('change_track', result.call)
     error = 'Track already exists'  # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #10
0
 def test_change_track_passes(self):
     # Arrange
     track = Track.objects.create(name='bogus track',
                                  distance=50,
                                  timeout=100,
                                  unit_of_measurement=settings.METRIC)
     # Act
     result = api_track.change_track(
         track_name='bogus track',
         new_track_name='bogus track 2',
         new_track_distance=51,
         new_lap_timeout=101,
         new_unit_of_measurement=settings.IMPERIAL)
     # Assert
     self.assertTrue(result.ok)
     self.assertEqual('change_track', result.call)
     track = Track.objects.get(name='bogus track 2')
     self.assertEqual(track, result.data)
     self.assertEqual(51, track.distance)
     self.assertEqual(101, track.timeout)
     self.assertEqual(settings.IMPERIAL, track.unit_of_measurement)