Beispiel #1
0
    def test_005_test_sdp_records(self):
	# make sure we have an empty DB
	pks=methods.getLockOverRecords(models.uploadFoundRecord)
	methods.deleteRecords(models.uploadFoundRecord, pks)

	camp1 = op_models.MarketingCampaign(service=0, enabled=False, start=None, end=None)
	camp2 = op_models.MarketingCampaign(service=1, enabled=False, start=None, end=None)
	camp1.save()
	camp2.save()

	amount_records=randrange(10,30)
	self.__generate_sdp_records(amount_records)

	camp1.enabled=True
	camp1.save()
	self.__generate_sdp_records(amount_records)

	camp2.enabled=True
	camp2.save()
	self.__generate_sdp_records(amount_records)

	pks=methods.getLockOverRecords(models.uploadSDPRecord)
	self.assertEqual(amount_records*3, len(pks))
	records = methods.getRecordsForUpload(models.uploadSDPRecord, pks)
	self.assertEqual(amount_records*3, methods.unlockRecords(models.uploadSDPRecord, pks))
	self.assertEqual(methods.deleteRecords(models.uploadSDPRecord, pks), None)
	self.assertEqual(amount_records*3, op_models.RemoteBluetoothDeviceSDP.objects.count())
	self.assertEqual(0, len(methods.getRecordsForUpload(models.uploadSDPRecord, pks)))

	op_models.MarketingCampaign.objects.filter(pk__in=[camp1.pk, camp2.pk]).delete()
Beispiel #2
0
    def test_003_test_found_records(self):
	# make sure we have an empty DB
	pks=methods.getLockOverRecords(models.uploadFoundRecord)
	methods.deleteRecords(models.uploadFoundRecord, pks)

	amount_records=randrange(10,30)
	self.__generate_found_records(amount_records)

	pks=methods.getLockOverRecords(models.uploadFoundRecord)
	self.assertEqual(amount_records, len(pks))
	records = methods.getRecordsForUpload(models.uploadFoundRecord, pks)
	self.assertEqual(amount_records, methods.unlockRecords(models.uploadFoundRecord, pks))
	self.assertEqual(methods.deleteRecords(models.uploadFoundRecord, pks), None)
	self.assertEqual(amount_records, op_models.RemoteBluetoothDeviceFoundRecord.objects.count())
	self.assertEqual(0, len(methods.getRecordsForUpload(models.uploadFoundRecord, pks)))