![]() It’s a good thing I did a curl request earlier to see what the actual response will be. There’s some fancy things I see like registering URIs, but to start, I am just going use the Mocker example they have. Let’s mock consul.Īs I alluded at the top of my post, I hope to solve this with requests-mock. My code is still perfectly fine, but because the live data has changed, my test fails. (p圓) jh1:mocktests ytjohn$ python test.pyįAIL: test_foo (_main_.TestStringMethods) This works great! But what if the consul server on the CICD server running my test.py has a different value for foo? Or no consul server at all? (p圓) jh1:mocktests ytjohn$ consul kv delete foo import unittestĬlass TestStringMethods(unittest.TestCase): This will ensure the value of foo is equal to bar. # FYI v will return a byte instead of a string (b'foo'), we'll decode that to a string Read consul with python requestsĪwesome, now I can write a fancy python script to show off my foo. Running echo YmFy | base64 -d will give you the string bar. That’s because consul uses base64 encoding. You may be wondering why “Value” is YmFy. ![]() Be verbose, because there are some headers you’ll want later.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |