Esempio n. 1
0
 def test_call_success_posts_to_callback_url(self):
     callback.call_success(self.fixture)
     postdata = {"applied_hash": callback.hash_deployment_config(self.fixture)}
     self.mock_post.assert_called_once_with(
         self.fixture["callback_url"],
         data=postdata,
         headers={'User-Agent': 'nodeconfig/callback for appname1'},
         verify=True)
Esempio n. 2
0
    def test_call_error_posts_to_callback_url(self):
        log = ["a", "b", "c"]
        e = Exception
        callback.call_error(self.fixture, callback, e, log)

        postdata = {"applied_hash": callback.hash_deployment_config(self.fixture),
                    "error": e,
                    "module": callback.__name__,
                    "log": "\n".join(log)}

        self.mock_post.assert_called_once_with(self.fixture["callback_url"],
                                               data=postdata,
                                               headers={'User-Agent': 'nodeconfig/callback for appname1'},
                                               verify=True)
Esempio n. 3
0
 def test_hash_deployment_config_returns_sha256_string(self):
     # hash is hex and 128 bits long
     hash = callback.hash_deployment_config(self.fixture)
     self.assertRegexpMatches(hash, r'^[a-f0-9]*$')
     self.assertEquals(len(hash), 128)
Esempio n. 4
0
 def test_hash_deployment_returns_correct_hash(self):
     hash = hashlib.sha512(json.dumps(self.fixture)).hexdigest()
     self.assertEqual(hash, callback.hash_deployment_config(self.fixture))