Esempio n. 1
0
    def test_get_entire_data_from_db_but_it_does_not_exist(self, _get_db_data):
        _get_db_data.return_value = ()

        rg = "12345"
        data_controller = DataTrafficController(rg=rg)
        with pytest.raises(DataDoesNotExistException):
            data_controller.get_data()

        _get_db_data.assert_called_once_with()
Esempio n. 2
0
    def test_get_entire_data_from_already_with_photo(self, _get_db_data,
                                                     _get_db_photo,
                                                     _request_photo,
                                                     _serialize):
        _get_db_data.return_value = {"rg": "12345"}
        _serialize.return_value = {"ser_data": 1}
        _get_db_photo.return_value = "b64_img"

        rg = "12345"
        data_controller = DataTrafficController(rg=rg)
        data = data_controller.get_data()
        expected_data = {"ser_data": 1, "photo": "b64_img"}

        _get_db_data.assert_called_once_with()
        _serialize.assert_called_once_with({"rg": "12345"})
        _get_db_photo.assert_called_once_with()
        _request_photo.assert_not_called()
        assert data == expected_data