Esempio n. 1
0
    def testFillSectionWithValidData(self):
        testMovesSec = {}
        testMovesSec['manual'] = True
        testMovesSec['startTime'] = "20140407T183039-0700"
        testMovesSec['endTime'] = "20140407T191539-0700"
        testMovesSec['duration'] = 45
        testMovesSec['distance'] = 10
        testMovesSec['trackPoints'] = [{
            u'lat': 37,
            u'lon': -122,
            u'time': u'20140407T083200-0700'
        }, {
            u'lat': 38,
            u'lon': -123,
            u'time': u'20140407T083220-0700'
        }]

        newSec = {}
        collect.fillSectionWithMovesData(testMovesSec, newSec)

        self.assertEquals(newSec['manual'], True)
        self.assertEquals(newSec['section_start_time'], "20140407T183039-0700")
        self.assertEquals(newSec['section_end_time'], "20140407T191539-0700")
        self.assertEquals(newSec['section_start_datetime'].month, 04)
        self.assertEquals(newSec['section_end_datetime'].hour, 19)
        self.assertEquals(newSec['duration'], 45)
        self.assertEquals(newSec['distance'], 10)

        self.assertEquals(len(newSec['track_points']), 2)
        self.assertEquals(newSec['section_start_point']['coordinates'],
                          [-122, 37])
        self.assertEquals(newSec['section_end_point']['coordinates'],
                          [-123, 38])
Esempio n. 2
0
    def testSectionFilterLabeling(self):
        """
    Tests that incoming section data parsed by collect.py is properly 
    labeled with a filter flag
    """
        # Testing first outer if statement in label_filtered
        testMovesSec = {}
        testMovesSec['manual'] = True
        testMovesSec['startTime'] = "20140407T183039-0700"
        testMovesSec['endTime'] = "20140407T191539-0700"
        testMovesSec['trackPoints'] = [{
            u'lat': 37,
            u'lon': -122,
            u'time': u'20140407T083200-0700'
        }, {
            u'lat': 38,
            u'lon': -123,
            u'time': u'20140407T083220-0700'
        }]

        newSec = {'mode': ''}
        collect.fillSectionWithMovesData(testMovesSec, newSec)
        collect.label_filtered_section(newSec)
        self.assertEquals(newSec['retained'], True)

        # Testing first outer elif statement in label_filtered
        testMovesSec['trackPoints'] = []
        newSec = {'mode': ''}
        collect.fillSectionWithMovesData(testMovesSec, newSec)
        collect.label_filtered_section(newSec)
        self.assertEquals(newSec['retained'], True)

        # Testing second outer elif statement in label_filtered
        testMovesSec['startTime'] = ""
        testMovesSec['endTime'] = ""
        testMovesSec['trackPoints'] = [{
            u'lat': 37,
            u'lon': -122,
            u'time': u'20140407T083200-0700'
        }, {
            u'lat': 38,
            u'lon': -123,
            u'time': u'20140407T083220-0700'
        }]

        newSec = {'mode': ''}
        collect.fillSectionWithMovesData(testMovesSec, newSec)
        collect.label_filtered_section(newSec)
        self.assertEquals(newSec['retained'], True)

        # Testing outer else statement in label_filtered
        testMovesSec['startTime'] = ""
        testMovesSec['endTime'] = ""
        testMovesSec['trackPoints'] = ""

        newSec = {'mode': ''}
        collect.fillSectionWithMovesData(testMovesSec, newSec)
        collect.label_filtered_section(newSec)
        self.assertEquals(newSec['retained'], False)
Esempio n. 3
0
    def testFillSectionWithInvalidData(self):
        testMovesSec = {}
        newSec = {}
        collect.fillSectionWithMovesData(testMovesSec, newSec)

        self.assertEquals(newSec['manual'], None)

        # SHANKARI Unsure why this is '' instead of None. Will check with Mogeng on
        # it and then try to nomalize them
        self.assertEquals(newSec['section_start_time'], '')
        self.assertEquals(newSec['section_end_time'], '')
        # self.assertEquals(newSec['section_start_datetime'], )
        # self.assertEquals(newSec['section_end_datetime'], )
        self.assertEquals(newSec['duration'], None)
        self.assertEquals(newSec['distance'], None)

        self.assertEquals(len(newSec['track_points']), 0)
        self.assertEquals(newSec['section_start_point'], None)
        self.assertEquals(newSec['section_end_point'], None)
  def testFillSectionWithInvalidData(self):
    testMovesSec = {}
    newSec = {} 
    collect.fillSectionWithMovesData(testMovesSec, newSec)

    self.assertEquals(newSec['manual'], None)

    # SHANKARI Unsure why this is '' instead of None. Will check with Mogeng on
    # it and then try to nomalize them
    self.assertEquals(newSec['section_start_time'], '')
    self.assertEquals(newSec['section_end_time'], '')
    # self.assertEquals(newSec['section_start_datetime'], )
    # self.assertEquals(newSec['section_end_datetime'], )
    self.assertEquals(newSec['duration'], None)
    self.assertEquals(newSec['distance'], None)

    self.assertEquals(len(newSec['track_points']), 0)
    self.assertEquals(newSec['section_start_point'], None)
    self.assertEquals(newSec['section_end_point'], None)
  def testSectionFilterLabeling(self):
    """
    Tests that incoming section data parsed by collect.py is properly 
    labeled with a filter flag
    """
    # Testing first outer if statement in label_filtered
    testMovesSec = {}
    testMovesSec['manual'] = True
    testMovesSec['startTime'] = "20140407T183039-0700"
    testMovesSec['endTime'] = "20140407T191539-0700"
    testMovesSec['trackPoints'] = [{u'lat': 37, u'lon': -122, u'time': u'20140407T083200-0700'},
                                   {u'lat': 38, u'lon': -123, u'time': u'20140407T083220-0700'}]

    newSec = {'mode': ''} 
    collect.fillSectionWithMovesData(testMovesSec, newSec)
    collect.label_filtered_section(newSec)
    self.assertEquals(newSec['retained'], True)

    # Testing first outer elif statement in label_filtered
    testMovesSec['trackPoints'] = []
    newSec = {'mode':''} 
    collect.fillSectionWithMovesData(testMovesSec, newSec)
    collect.label_filtered_section(newSec)
    self.assertEquals(newSec['retained'], True)

    # Testing second outer elif statement in label_filtered
    testMovesSec['startTime'] = ""
    testMovesSec['endTime'] = ""
    testMovesSec['trackPoints'] = [{u'lat': 37, u'lon': -122, u'time': u'20140407T083200-0700'},
                                   {u'lat': 38, u'lon': -123, u'time': u'20140407T083220-0700'}]


    newSec = {'mode':''} 
    collect.fillSectionWithMovesData(testMovesSec, newSec)
    collect.label_filtered_section(newSec)
    self.assertEquals(newSec['retained'], True)

    # Testing outer else statement in label_filtered
    testMovesSec['startTime'] = ""
    testMovesSec['endTime'] = ""
    testMovesSec['trackPoints'] = ""
    
    newSec = {'mode':''} 
    collect.fillSectionWithMovesData(testMovesSec, newSec)
    collect.label_filtered_section(newSec)
    self.assertEquals(newSec['retained'], False)
  def testFillSectionWithValidData(self):
    testMovesSec = {}
    testMovesSec['manual'] = True
    testMovesSec['startTime'] = "20140407T183039-0700"
    testMovesSec['endTime'] = "20140407T191539-0700"
    testMovesSec['duration'] = 45
    testMovesSec['distance'] = 10
    testMovesSec['trackPoints'] = [{u'lat': 37, u'lon': -122, u'time': u'20140407T083200-0700'},
                                   {u'lat': 38, u'lon': -123, u'time': u'20140407T083220-0700'}]

    newSec = {} 
    collect.fillSectionWithMovesData(testMovesSec, newSec)

    self.assertEquals(newSec['manual'], True)
    self.assertEquals(newSec['section_start_time'], "20140407T183039-0700")
    self.assertEquals(newSec['section_end_time'], "20140407T191539-0700")
    self.assertEquals(newSec['section_start_datetime'].month, 04)
    self.assertEquals(newSec['section_end_datetime'].hour, 19)
    self.assertEquals(newSec['duration'], 45)
    self.assertEquals(newSec['distance'], 10)

    self.assertEquals(len(newSec['track_points']), 2)
    self.assertEquals(newSec['section_start_point']['coordinates'], [-122, 37])
    self.assertEquals(newSec['section_end_point']['coordinates'], [-123, 38])