UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit 9dc68b1d authored by Garrett Heaton's avatar Garrett Heaton
Browse files

Merge branch 'fix_for_test_modify' into 'master'

switch to mongo samples instead of random for tests

See merge request 90cos/mttl!305
parents a446c17a d223eccd
No related branches found
No related tags found
1 merge request!305switch to mongo samples instead of random for tests
Pipeline #90364 failed
......@@ -23,9 +23,13 @@ class TestMethods(unittest.TestCase):
def test_insert_rel_link_mapping(self):
num_items = 1
rand_num = random.randrange(1, 100)
test_rels = list(rls.find({'map_for': 'training'}).skip(rand_num).limit(num_items))
test_ksats = list(reqs.find({}).skip(rand_num).limit(num_items))
test_rels = list(rls.aggregate([
{'$match': {'map_for': 'training'}},
{'$sample': { 'size':num_items }}
]))
test_ksats = list(reqs.aggregate([
{'$sample': { 'size':num_items }}
]))
for i, test_rel in enumerate(test_rels):
test_ksat = test_ksats[i]
......@@ -37,7 +41,7 @@ class TestMethods(unittest.TestCase):
# def test_modify_mapping_url(self):
# num_items = 1
# rand_num = random.randrange(1, 100)
# rand_num = random.randrange(1, 10)
# test_rels = list(rls.find({'KSATs': {'$not': {'$size': 0}}}).skip(rand_num).limit(num_items))
# for test_rel in test_rels:
......@@ -51,7 +55,7 @@ class TestMethods(unittest.TestCase):
# def test_modify_mapping_prof(self):
# num_items = 1
# rand_num = random.randrange(1, 100)
# rand_num = random.randrange(1, 10)
# test_rels = list(rls.find({'KSATs': {'$not': {'$size': 0}}}).skip(rand_num).limit(num_items))
# for test_rel in test_rels:
......@@ -64,8 +68,10 @@ class TestMethods(unittest.TestCase):
# self.assertEqual(modified_rel_count, 1)
def test_delete_mapping(self):
rand_num = random.randrange(1, 100)
test_rel = list(rls.find({'KSATs': {'$not': {'$size': 0}}, 'map_for': 'training'}).skip(rand_num).limit(1))[0]
test_rel = list(rls.aggregate([
{'$match': {'KSATs': {'$not': {'$size': 0}}, 'map_for': 'training'}},
{'$sample': { 'size':1 }}
]))[0]
find_query = json.dumps({'_id': str(test_rel['_id'])}, separators=(',', ':'))
cmd = f"python3 mttl.py modify rel-link -d {find_query}".split()
......@@ -77,9 +83,10 @@ class TestMethods(unittest.TestCase):
self.assertEqual(len(modified_rel['KSATs']), 0)
def test_modify_update_ksat_id(self):
rand_num = random.randrange(1, 100)
num_items = 1
test_ksats = list(reqs.find({}).skip(rand_num).limit(num_items))
test_ksats = list(reqs.aggregate([
{'$sample': { 'size':num_items }}
]))
old_ksats = [ksat['ksat_id'] for ksat in test_ksats]
new_ksats = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment