Browse Source

Fixing/updating insert/read test scripts

master
Charles Reid 1 year ago
parent
commit
3430903e93
3 changed files with 25 additions and 40 deletions
  1. +10
    -26
      test/test_mongo_insert.py
  2. +15
    -0
      test/test_mongo_read.py
  3. +0
    -14
      test/test_mongo_retrieve.py

+ 10
- 26
test/test_mongo_insert.py View File

@@ -1,35 +1,19 @@
from pymongo import MongoClient
import random
from datetime import datetime

client = MongoClient('localhost', 27017)
client = MongoClient('10.6.0.1', 27017)
db = client.test_database
collection = db.test_collection

docs = [{
'timestamp' : '2017-04-11 11:04:12',
'bssid' : 'DEADBEEFSFUOESIEWR',
'channel' : random.randint(0,100),
'ssid' : 'wiiiiiifi',
'strength' : -24,
'encryption' : 'WPA'
},
{
'timestamp' : '2017-04-11 11:01:12',
'bssid' : 'BEEOIEUDSJFLKSDJFF',
'channel' : random.randint(0,100),
'ssid' : 'iurtiruyiuyrwe',
'strength' : -20,
'encryption' : 'WPA'
},
{
'timestamp' : '2017-04-11 11:24:12',
'bssid' : 'BEEF2DJFSKJFLKJSFKJL',
'channel' : random.randint(0,100),
'ssid' : 'sdfjaskfjlkdfjglfdghfketa',
'strength' : -30,
'encryption' : 'WPA'
}]
docs = []
for i in range(20):
d = {
'timestamp' : datetime.now(),
'channel' : random.randint(1000,8000)
}
docs.append(d)

result = collection.insert_many(docs)
print result.inserted_ids
print(result.inserted_ids)


+ 15
- 0
test/test_mongo_read.py View File

@@ -0,0 +1,15 @@
from pymongo import MongoClient

"""
Test Read

Tests the ability to read records from the database.
"""

client = MongoClient('10.6.0.1', 27017)
db = client.test_database
collection = db.test_collection

for doc in collection.find():
print(doc)


+ 0
- 14
test/test_mongo_retrieve.py View File

@@ -1,14 +0,0 @@
from pymongo import MongoClient
import random

client = MongoClient('localhost', 27017)
db = client.test_database
collection = db.test_collection

# Note:
# The space in front of the askterisk is important.
# (Got it working through trial and error: W* worked, *A didn't, so * as leading character led to problems.)
for doc in collection.find({'encryption':{'$regex':' *'}}):
print "Channel: %d \tNetwork bssid: %s"%( doc['channel'], doc['bssid'] )



Loading…
Cancel
Save