Esempio n. 1
0
    def _stub_response(self, url, response_json, status=None):
        if not is_string(response_json):
            response_json = json.dumps(response_json)

        kwargs = dicts.AbsentDict({
            'body': response_json,
            'content_type': self.MIME_TYPE,
            'status': status or dicts.ABSENT,
        })
        responses.add(responses.GET, str(url), **kwargs)
Esempio n. 2
0
 def test_setitem__still_absent(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ONE_ABSENT)
     dict_[self.ABSENT_KEY] = __unit__.ABSENT  # should be no-op
     self.assertNotIn(self.ABSENT_KEY, dict_)
Esempio n. 3
0
 def test_setitem__absent_to_present(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ONE_ABSENT)
     dict_[self.ABSENT_KEY] = 42  # should add the key
     self.assertIn(self.ABSENT_KEY, dict_)
Esempio n. 4
0
 def test_setitem__present_to_absent(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ALL_PRESENT)
     dict_[self.EXISTING_KEY] = __unit__.ABSENT  # should delete the key
     self.assertNotIn(self.EXISTING_KEY, dict_)
Esempio n. 5
0
 def test_setitem__nonexisting_present(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ALL_PRESENT)
     dict_[self.NONEXISTING_KEY] = 42  # should add the key normally
     self.assertIn(self.NONEXISTING_KEY, dict_)
Esempio n. 6
0
 def test_setitem__existing_present(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ALL_PRESENT)
     dict_[self.EXISTING_KEY] = self.EXISTING_VALUE  # should be no-op
     self.assertEquals(self.DICT_WITH_ALL_PRESENT, dict_)
Esempio n. 7
0
 def test_ctor__pairlist__all_absent(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ALL_ABSENT.items())
     self.assertEquals({}, dict_)
Esempio n. 8
0
 def test_ctor__pairlist__one_absent(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ONE_ABSENT.items())
     self.assertEquals(len(self.DICT_WITH_ONE_ABSENT) - 1, len(dict_))
     self.assertNotIn(self.ABSENT_KEY, dict_)
Esempio n. 9
0
 def test_ctor__pairlist__empty(self):
     self.assertEquals({}, __unit__.AbsentDict([]))
Esempio n. 10
0
 def test_ctor__dict__all_absent(self):
     self.assertEquals({}, __unit__.AbsentDict(self.DICT_WITH_ALL_ABSENT))
Esempio n. 11
0
 def test_ctor__dict__all_present(self):
     dict_ = __unit__.AbsentDict(self.DICT_WITH_ALL_PRESENT)
     self.assertEquals(self.DICT_WITH_ALL_PRESENT, dict_)
Esempio n. 12
0
 def test_ctor__dict__empty(self):
     self.assertEquals({}, __unit__.AbsentDict({}))
Esempio n. 13
0
 def test_ctor__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.AbsentDict(object())
Esempio n. 14
0
 def test_ctor__none(self):
     with self.assertRaises(TypeError):
         __unit__.AbsentDict(None)
Esempio n. 15
0
 def test_ctor__no_args(self):
     dict_ = __unit__.AbsentDict()
     self._assertIsMapping(dict_)
     self.assertEmpty(dict_)