Beispiel #1
0
 def test_add_session_fails_when_track_not_found(self):
     # Arrange & Act
     result = api_session.add_session('bogus track', 'bogus session')
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('add_session', result.call)
     error = 'Track not found' # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #2
0
 def test_add_session_fails_when_name_invalid(self):
     # Arrange
     track = Track.objects.create(name='bogus track', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     # Act
     result = api_session.add_session(track_name=track.name, 
         session_name=None)
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('add_session', result.call)
     self.assertEqual('IntegrityError', result.data)
Beispiel #3
0
 def test_add_session_passes(self):
     # Arrange
     track = Track.objects.create(name='bogus track', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     session_name = 'bogus session'
     # Act
     result = api_session.add_session(track.name, session_name)
     # Assert
     self.assertTrue(Session.objects.filter(name=session_name).exists())
     self.assertTrue(result.ok)
     self.assertEqual('add_session', result.call)
     session = Session.objects.get(name=session_name)
     self.assertEqual(session, result.data)
Beispiel #4
0
 def test_add_session_fails_when_session_found(self):
     # Arrange
     track = Track.objects.create(name='bogus track', distance=50,
         timeout=100, unit_of_measurement=settings.METRIC)
     session = Session.objects.create(name='bogus session', 
         track_id=track.id)
     # Act
     result = api_session.add_session(track.name, session.name)
     # Assert
     self.assertFalse(result.ok)
     self.assertEqual('add_session', result.call)
     error = 'Session already exists' # TODO: i18n
     self.assertEqual(error, result.data)
Beispiel #5
0
from django.conf import settings
from laptimer import api_lap, \
      api_rider, \
      api_session, \
      api_track
#api_sensor, \
from laptimer.models import Lap, \
                            Rider, \
                            Session, \
                            Sensor, \
                            SensorEvent, \
                            Track
import logging

logger = logging.getLogger('laptimer')

# Create test data via api, assumes db is flushed
riderBetty = api_rider.add_rider(rider_name='Bodacious Betty').data
riderBob = api_rider.add_rider(rider_name='Bogus Bob').data
track = api_track.add_track(track_name='Test Track',
                            track_distance=50,
                            lap_timeout=100,
                            unit_of_measurement=settings.METRIC).data
session = api_session.add_session(track.name, 'Test Session').data
# sensorStart = api_sensor.add_sensor()
# sensorFinish = api_sensor.add_sensor()
# sensorStartFinish = api_sensor.add_sensor()
# riderBettyLap1 = api_lap.add_lap()
# riderBobLap1 = api_lap.add_lap()
Beispiel #6
0
from django.conf import settings
from laptimer import api_lap, \
					 api_rider, \
					 api_session, \
					 api_track
					 #api_sensor, \
from laptimer.models import Lap, \
                            Rider, \
                            Session, \
                            Sensor, \
                            SensorEvent, \
                            Track
import logging


logger = logging.getLogger('laptimer')

# Create test data via api, assumes db is flushed
riderBetty = api_rider.add_rider(rider_name='Bodacious Betty').data
riderBob = api_rider.add_rider(rider_name='Bogus Bob').data
track = api_track.add_track(track_name='Test Track', track_distance=50, 
	lap_timeout=100, unit_of_measurement=settings.METRIC).data
session = api_session.add_session(track.name, 'Test Session').data
# sensorStart = api_sensor.add_sensor()
# sensorFinish = api_sensor.add_sensor()
# sensorStartFinish = api_sensor.add_sensor()
# riderBettyLap1 = api_lap.add_lap()
# riderBobLap1 = api_lap.add_lap()