def test_refresh_from_sets_all_values_to_object(self):
        obj = TwitchObject()
        obj.refresh_from({'spongebob': 'squarepants', 'patrick': 'star', '_id': 1234})

        assert obj.spongebob == 'squarepants'
        assert obj['patrick'] == 'star'
        assert obj.id == 1234
Пример #2
0
    def test_refresh_from_sets_all_values_to_object(self):
        obj = TwitchObject()
        obj.refresh_from({
            "spongebob": "squarepants",
            "patrick": "star",
            "_id": 1234
        })

        assert obj.spongebob == "squarepants"
        assert obj["patrick"] == "star"
        assert obj.id == 1234
    def test_attributes_are_stored_and_fetched_from_dict(self):
        obj = TwitchObject()
        value = 'spongebob'
        obj.spongebob = value

        assert 'spongebob' in obj
        assert '_spongebob' not in obj.__dict__
        assert 'spongebob' not in obj.__dict__
        assert obj['spongebob'] == value
        assert obj.spongebob == value

        del obj.spongebob

        assert 'spongebob' not in obj
        assert 'spongebob' not in obj.__dict__
Пример #4
0
    def test_attributes_are_stored_and_fetched_from_dict(self):
        obj = TwitchObject()
        value = "spongebob"
        obj.spongebob = value

        assert "spongebob" in obj
        assert "_spongebob" not in obj.__dict__
        assert "spongebob" not in obj.__dict__
        assert obj["spongebob"] == value
        assert obj.spongebob == value

        del obj.spongebob

        assert "spongebob" not in obj
        assert "spongebob" not in obj.__dict__
 def test_setitem_removes_underscore_prefix(self):
     obj = TwitchObject()
     value = 'squarepants'
     obj['_spongebob'] = value
     assert obj['spongebob'] == value
     assert '_spongebob' not in obj
     assert '_spongebob' not in obj.__dict__
    def test_prefixed_attributes_are_stored_on_the_object(self):
        obj = TwitchObject()
        value = 'spongebob'
        obj._spongebob = value

        obj._spongebob
        getattr(obj, '_spongebob')
        assert 'spongebob' not in obj
        assert '_spongebob' not in obj
        assert '_spongebob' in obj.__dict__
        assert obj._spongebob == value

        del obj._spongebob

        assert 'spongebob' not in obj
        assert 'spongebob' not in obj.__dict__
Пример #7
0
 def test_setitem_removes_underscore_prefix(self):
     obj = TwitchObject()
     value = "squarepants"
     obj["_spongebob"] = value
     assert obj["spongebob"] == value
     assert "_spongebob" not in obj
     assert "_spongebob" not in obj.__dict__
Пример #8
0
    def test_prefixed_attributes_are_stored_on_the_object(self):
        obj = TwitchObject()
        value = "spongebob"
        obj._spongebob = value

        obj._spongebob
        getattr(obj, "_spongebob")
        assert "spongebob" not in obj
        assert "_spongebob" not in obj
        assert "_spongebob" in obj.__dict__
        assert obj._spongebob == value

        del obj._spongebob

        assert "spongebob" not in obj
        assert "spongebob" not in obj.__dict__
 def test_setitem_sets_item_to_dict(self):
     obj = TwitchObject()
     value = 'squarepants'
     obj['spongebob'] = value
     assert obj['spongebob'] == value
Пример #10
0
 def test_construct_form_returns_class_with_set_values(self):
     obj = TwitchObject.construct_from({'spongebob': 'squarepants'})
     assert isinstance(obj, TwitchObject)
     assert obj.spongebob == 'squarepants'
Пример #11
0
 def test_setitem_sets_item_to_dict(self):
     obj = TwitchObject()
     value = "squarepants"
     obj["spongebob"] = value
     assert obj["spongebob"] == value