Exemple #1
0
    def test(self):
        truncateTable('outgoing_autonomous')
        dao = OutgoingAutonomousDAO(defaultConfigPath())

        testIns = outgoing_autonomous()
        testIns.crop_id = 42
        testIns.shape = 'circle'
        testIns.background_color = 'white'
        testIns.alphanumeric = 'A'
        testIns.alphanumeric_color = 'black'
        resultingId = dao.addClassification(testIns)
        self.assertNotEqual(resultingId, -1)

        # should not be able to insert a duplicate record
        self.assertEqual(dao.addClassification(testIns), -1)
        self.assertIsNotNone(dao.getClassification(resultingId))
Exemple #2
0
    def test(self):
        truncateTable('outgoing_autonomous')
        dao = OutgoingAutonomousDAO(defaultConfigPath())

        # empty table
        self.assertIsNone(dao.getUnlocatedClassifications())

        # populate with two classifications that need geo, one that doesnt
        testIns = outgoing_manual()
        testIns.crop_id = 42
        testIns.shape = 'circle'
        testIns.background_color = 'white'
        testIns.alphanumeric = 'A'
        testIns.alphanumeric_color = 'black'

        resultingId = dao.addClassification(testIns)
        self.assertNotEqual(resultingId, -1)

        testIns.crop_id = 43
        testIns.background_color = 'orange'
        resultingId2 = dao.addClassification(testIns)
        self.assertNotEqual(resultingId2, -1)

        testIns.crop_id = 44
        testIns.latitude = 40.111
        testIns.longitude = -111.222
        resultingId3 = dao.addClassification(testIns)
        self.assertNotEqual(resultingId3, -1)

        unlocated = dao.getUnlocatedClassifications()
        self.assertIsNotNone(unlocated)
        self.assertEqual(len(unlocated), 2)
        # the two models in the list should be our first two inserts and have
        # crop ids 42 and 43
        self.assertLess(unlocated[0].crop_id, 44)
        self.assertLess(unlocated[1].crop_id, 44)
Exemple #3
0
    def test(self):
        truncateTable('incoming_image')
        truncateTable('cropped_autonomous')
        truncateTable('outgoing_autonomous')
        dao = OutgoingAutonomousDAO(defaultConfigPath())

        testIns = outgoing_autonomous()
        testIns.crop_id = 42
        testIns.shape = 'circle'
        testIns.background_color = 'white'
        testIns.alphanumeric = 'A'
        testIns.alphanumeric_color = 'black'
        self.assertNotEqual(dao.addClassification(testIns), -1)

        dao = CroppedAutonomousDAO(defaultConfigPath())
        model = cropped_autonomous()
        model.image_id = 123
        model.time_stamp = 1547453775.2
        model.cropped_path = '/im/a/totally/real/cropped/path/i/swear.jpg'
        model.crop_coordinate_br = "(12, 34)"
        model.crop_coordinate_tl = "(56, 78)"
        self.assertNotEqual(dao.addImage(model), -1)

        dao = IncomingImageDAO(defaultConfigPath())
        model = incoming_image()
        model.time_stamp = 1547453775.2
        model.focal_length = 16.0
        model.image_path = '/im/a/totally/real/path/i/swear.jpg'
        model.manual_tap = True
        model.autonomous_tap = True
        resultingId = dao.addImage(model)
        self.assertNotEqual(resultingId, -1)

        util = UtilDAO(defaultConfigPath())
        util.resetAutonomousDB()

        resultingModel = dao.getImage(resultingId)
        self.assertIsNotNone(resultingModel)
        self.assertFalse(resultingModel.autonomous_tap)
        self.assertTrue(resultingModel.manual_tap)
        self.assertEqual(resultingModel.image_path, model.image_path)
        self.assertEqual(resultingModel.focal_length, model.focal_length)

        dao = CroppedAutonomousDAO(defaultConfigPath())
        self.assertEqual(len(dao.getAll()), 0)

        dao = OutgoingAutonomousDAO(defaultConfigPath())
        self.assertEqual(len(dao.getAll()), 0)