method='DELETE') response = self.wait() assert response.code == 204 def test_6_listing_again(self): self.http_client.fetch(self.get_url('/person'), self.stop) response = self.wait() assert response.code == 200 assert len(simplejson.loads(response.body)) == 1 def test_7_delete_2(self): self.http_client.fetch(self.get_url('/person/%s' % self.facebook_id_2), self.stop, method='DELETE') response = self.wait() assert response.code == 204 def test_8_listing_nothing(self): self.http_client.fetch(self.get_url('/person'), self.stop) response = self.wait() assert response.code == 200 assert len(simplejson.loads(response.body)) == 0 def all(): return TestLoader().loadTestsFromModule(sys.modules[__name__]) if __name__ == '__main__': main()
def test_invite_unauthorized(self): logging.debug("Start test_invite_unauthorized") request = yield get_ws_request(self.io_loop, username="******") connection = yield websocket_connect(request) correlation = str(uuid.uuid4())[:10] connection.write_message(json.dumps({ "action": "invitations", "operation": "create", "correlation": correlation, "body": dict() })) message = yield wait_message(connection, correlation) validate_response( self, message, dict(status_code=403, correlation=correlation, operation="create", action="invitations", body_type=dict)) expected_message = "Operation create forbidden for action invitations." self.assertTrue(message["body"]["message"] == expected_message, "Message is %s instead of '%s'" % (message["body"]["message"], expected_message)) connection.close() logging.debug("Completed test_invite_unauthorized") if __name__ == "__main__": testing.main()
user = { 'chat_id': 0, 'current_location': [0., 0.] } drivers = [] future_get_drivers = Future() future_get_drivers.set_result(drivers) self.users.get_drivers_within_distance = mock.MagicMock( return_value=future_get_drivers ) yield self.stage.run(user, {}) self.stage.sender.assert_has_calls([ mock.call({ 'chat_id': 0, 'text': 'looking for a driver' }), mock.call({ 'chat_id': 0, 'text': 'no available drivers found' }) ]) self.assertEqual(2,self.stage.sender.call_count) self.assertEqual(None, user['proposed_driver']) if __name__ == "__main__": main()
def forbidden_update_test(self): logging.debug("Start forbidden_update_test") request = yield get_ws_request(self.io_loop, username="******") connection = yield websocket_connect(request) correlation = str(uuid.uuid4())[:10] connection.write_message(json.dumps({ "action": "settings", "operation": "update", "correlation": correlation, "body": dict() })) message = yield wait_message(connection, correlation) validate_response( self, message, dict(status_code=403, correlation=correlation, operation="update", action="settings", body_type=dict)) expected_message = "Operation update forbidden for action settings." self.assertTrue(message["body"]["message"] == expected_message, "Message is %s instead of '%s'" % (message["body"]["message"], expected_message)) connection.close() logging.debug("Completed forbidden_update_test") if __name__ == "__main__": testing.main()
# the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, # SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """Juju GUI server test suite entry point.""" import os import unittest from tornado import testing def all(): """This is required by the Tornado test runner. See <http://www.tornadoweb.org/en/stable/testing.html#test-runner>. """ path = os.path.dirname(__file__) return unittest.defaultTestLoader.discover(path) if __name__ == '__main__': testing.main(verbosity=2)
tools.assert_true(chan.done()) def test_exception_handling(self): class CrackWhoresAnonymousException(Exception): """ Ah git mah 3-month coin next week! """ pass with scoped_targets(1) as (t,): t.callable = lambda: blow_up( CrackWhoresAnonymousException("Crackies!")) tools.assert_raises( CrackWhoresAnonymousException, self.run_flo, [t]) with scoped_targets(1) as (inner,): inner.callable = lambda: blow_up( CrackWhoresAnonymousException("Deepa! Deepa!")) t = DependentTarget([inner]) tools.assert_raises( CrackWhoresAnonymousException, self.run_flo, [t]) if __name__ == '__main__': tt.main()
def run(): container.init() logging.getLogger("tornado.access").disabled = True main()
# This program is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License version 3, as published by # the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, # SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """Juju GUI server test suite entry point.""" import os import unittest from tornado import testing def all(): """This is required by the Tornado test runner. See <http://www.tornadoweb.org/en/stable/testing.html#test-runner>. """ path = os.path.dirname(__file__) return unittest.defaultTestLoader.discover(path) if __name__ == '__main__': testing.main(verbosity=2)