Commits

Eric Larson  committed 54b651e

Updated the tests for the simpleweb config and for restart

  • Participants
  • Parent commits 7f4ae99

Comments (0)

Files changed (1)

File dad/tests/unit/web/test_dad_api.py

 
     def test_get_service(self):
         h = httplib2.Http()
-        resp, content = h.request(self.base + '/services/hello_world')
+        resp, content = h.request(self.base + '/services/simpleweb')
         assert resp['status'] == '200'
         assert content
         result = simplejson.loads(content)
         actions = ['start', 'stop', 'start']
         for a in actions:
-            assert result[a] == '/services/hello_world/%s' % (a)
+            assert result[a] == '/services/simpleweb/%s' % (a)
 
     def test_start_service(self):
         resp, content = self.add_service()
         result = simplejson.loads(content)
 
         h = httplib2.Http()
-        resp, content = h.request(self.base + '/services/hello_world/stop',
+        resp, content = h.request(self.base + '/services/simpleweb/stop',
                                   method='POST',
                                   headers={'Content-Length': '0'})
         assert resp['status'] == '200'
         result = simplejson.loads(content)
         assert result
-        pprint(result)
         for port, output in result.iteritems():
-            assert output['returncode'] == -1
+            assert output['returncode'] == -15
+
+    def test_restart_service(self):
+        # start it if it isn't running
+        h = httplib2.Http()
+        resp, content = h.request(self.base + '/services/simpleweb/start',
+                                  method='POST',
+                                  headers={'Content-Length': '0'})
+        result = simplejson.loads(content)
+        assert result['started'] == 'simpleweb'
+        pids = result['pids']
+
+        resp, content = h.request(self.base + '/services/simpleweb/restart',
+                                  method='POST',
+                                  headers={'Content-Length': '0'})
+
+        pprint(resp)
+        print content
+
+        assert resp['status'] == '200'
+        result = simplejson.loads(content)
+        assert result['started'] == 'simpleweb'        
+        assert result['pids'] != pids
+
         
         
+        
+        
+