def testGetIgnoresTestSites(self): """Test sites should not be processed in the sites update.""" urllib2.urlopen.return_value = StringIO.StringIO("""[ { "site": "xyz0t", "metro": ["xyz0t", "xyz"], "created": 1310048316, "city": "Xyzville", "country": "AB", "latitude": null, "longitude": null }, { "site": "xyz01", "metro": ["xyz01", "xyz"], "created": 1310048316, "city": "Xyzville", "country": "AB", "latitude": 123.456789, "longitude": 34.567890 } ]""") model.Site.all.return_value = [mock.Mock(site_id='xyz01')] handler = update.SiteRegistrationHandler() handler.get() self.assertTrue(util.send_success.called) self.assertFalse(model.Site.called, 'Test site should not be added to the datastore')
def testUpdateExistingSites(self, mock_update): """Test updating an existing site.""" urllib2.urlopen.return_value = StringIO.StringIO("""[ { "site": "def01", "metro": ["def01", "def"], "created": 1310048316, "city": "Defville", "country": "DE", "latitude": 123.456789, "longitude": 34.567890, "roundrobin": false } ]""") db.Query.fetch.return_value = [mock.Mock(site_id='def01')] handler = update.SiteRegistrationHandler() handler.get() self.assertTrue(util.send_success.called) self.assertTrue(mock_update.called) self.assertTrue(model.Site.called, 'Update an existing site to the datastore')
def testGetIgnoresTestSites(self, mock_update): """Test sites should not be processed except in sandbox project.""" urllib2.urlopen.return_value = StringIO.StringIO("""[ { "site": "abc0t", "metro": ["abc0t", "abc"], "created": 1310048316, "city": "Abcville", "country": "AB", "latitude": null, "longitude": null, "roundrobin": false } ]""") db.Query.fetch.return_value = [mock.Mock(site_id='abc0t')] handler = update.SiteRegistrationHandler() handler.get() self.assertTrue(util.send_success.called) self.assertTrue(mock_update.called) self.assertFalse( model.Site.called, 'Test site should not be added to the staging datastore.')
def testGetIgnoresTestSites(self, mock_update): """Test sites should not be processed in the sites update.""" urllib2.urlopen.return_value = StringIO.StringIO("""[ { "site": "xyz0t", "metro": ["xyz0t", "xyz"], "created": 1310048316, "city": "Xyzville", "country": "AB", "latitude": null, "longitude": null, "roundrobin": false } ]""") app_identity.get_application_id.return_value = 'mlab-testing' db.Query.fetch.return_value = [mock.Mock(site_id='xyz01')] handler = update.SiteRegistrationHandler() handler.get() self.assertTrue(util.send_success.called) self.assertTrue(mock_update.called) self.assertFalse(model.Site.called, 'Test site should not be added to the datastore')