diff options
author | kabeer27 <32016558+kabeer27@users.noreply.github.com> | 2020-07-08 01:41:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 11:41:54 +1000 |
commit | 277886dee9edb205c64efd28625976df187dbe8c (patch) | |
tree | 722dce1b8cc85c4b684539cd6a0444155d498543 /infra/build | |
parent | c8279e2c2d1c16c15c8ffc1663308db61811c5ae (diff) | |
download | oss-fuzz-277886dee9edb205c64efd28625976df187dbe8c.tar.gz |
Resetting emulators (#4079)
* Resetting datastore emulator
* Resetting datastore emulator
* setUp class
Co-authored-by: Kabeer Seth <kabeerseth@google.com>
Diffstat (limited to 'infra/build')
-rw-r--r-- | infra/build/functions/sync/main_test.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/infra/build/functions/sync/main_test.py b/infra/build/functions/sync/main_test.py index 6023623f1..f49ea10e8 100644 --- a/infra/build/functions/sync/main_test.py +++ b/infra/build/functions/sync/main_test.py @@ -18,15 +18,17 @@ and uploads them to the Cloud Datastore.""" from collections import namedtuple import os -import unittest import subprocess import threading +import unittest + +import requests from google.cloud import ndb -from main import sync_projects -from main import get_projects from main import get_access_token +from main import get_projects +from main import sync_projects from main import Project _EMULATOR_TIMEOUT = 20 @@ -160,6 +162,11 @@ class TestDataSync(unittest.TestCase): os.environ['GCP_PROJECT'] = 'test-project' os.environ['FUNCTION_REGION'] = 'us-central1' + def setUp(self): + req = requests.post( + 'http://localhost:{}/reset'.format(_DATASTORE_EMULATOR_PORT)) + req.raise_for_status() + def test_sync_projects_update(self): """Testing sync_projects() updating a schedule.""" client = ndb.Client() @@ -180,8 +187,6 @@ class TestDataSync(unittest.TestCase): 'test1': '0 8 * * *', 'test2': '0 7 * * *' }, {project.name: project.schedule for project in projects_query}) - clean = [project.key for project in projects_query] - ndb.delete_multi(clean) def test_sync_projects_create(self): """"Testing sync_projects() creating new schedule.""" @@ -202,8 +207,6 @@ class TestDataSync(unittest.TestCase): 'test1': '0 8 * * *', 'test2': '0 7 * * *' }, {project.name: project.schedule for project in projects_query}) - clean = [project.key for project in projects_query] - ndb.delete_multi(clean) def test_sync_projects_delete(self): """Testing sync_projects() deleting.""" @@ -221,8 +224,6 @@ class TestDataSync(unittest.TestCase): self.assertEqual( {'test1': '0 8 * * *'}, {project.name: project.schedule for project in projects_query}) - clean = [project.key for project in projects_query] - ndb.delete_multi(clean) def test_get_projects_yaml(self): """Testing get_projects() yaml get_schedule().""" |