def test_sucessful_registration(self):
        self.fake_request.responses = [
            FakeResponse(200, {}),
            FakeResponse(200, {}),
            FakeResponse(200, [{
                "success": {
                    "username": "******"
                }
            }])
        ]

        store = {}
        assert register(Raw(""), HueApp("", ""), store).username == "abc"
        assert store == {"username": "******"}
    def test_unexpected_response(self):
        self.fake_request.responses = [FakeResponse(200, {})] * 3

        with pytest.raises(RegistrationFailed):
            register(Raw(""), HueApp("", ""), {}, 2)
 def test_registration_timeout(self):
     self.fake_request.responses = [FakeResponse(200, {})] * 30
     with pytest.raises(RegistrationFailed):
         register(Raw(""), HueApp("", ""), {}, 5)
    def test_bad_response(self):
        self.fake_request.responses = [FakeResponse(500, {})]

        with pytest.raises(RegistrationFailed):
            register(Raw(""), HueApp("", ""), {}, 30)
 def test_username_in_store(self):
     store = {"username": "******"}
     assert register(Raw(""), None, store).username == "test"