def test_pck_transformer_parse_yes_no_questions():
        """
        For QSS (Stocks), qcode 15 needs to converted from Yes/No to 1/0 for the pck.
        """
        survey = {'survey_id': '017'}

        # qcode 15 = Yes case
        response = {'collection': {'instrument_id': '0001'}, 'data': {'15': 'Yes', '146': 'Comment question', '139': '13900'}}
        pck_transformer = PCKTransformer(survey, response)
        assert pck_transformer.data == {'15': 'Yes', '146': 'Comment question', '139': '13900'}
        pck_transformer.parse_yes_no_questions()
        assert pck_transformer.data == {'15': '1', '146': 'Comment question', '139': '13900'}

        # qcode 15 = No case
        response = {'collection': {'instrument_id': '0001'}, 'data': {'15': 'No', '146': 'Comment question', '139': '13900'}}
        pck_transformer = PCKTransformer(survey, response)
        assert pck_transformer.data == {'15': 'No', '146': 'Comment question', '139': '13900'}
        pck_transformer.parse_yes_no_questions()
        assert pck_transformer.data == {'15': '0', '146': 'Comment question', '139': '13900'}
    def test_pck_transformer_parse_yes_no_construction_questions():
        survey = {'survey_id': '228'}

        # q code 902, 903, 904 yes
        response = {'collection': {'instrument_id': '0001'}, 'data': {'901': 'Yes, I can report for this period',
                                                                      '902': 'Yes, we carried out work on housing',
                                                                      '903': 'Yes, we carried out work on infrastructure',
                                                                      '904': 'Yes, we carried out other construction work'}}

        pck_transformer = PCKTransformer(survey, response)
        assert pck_transformer.data == {'901': 'Yes, I can report for this period',
                                        '902': 'Yes, we carried out work on housing',
                                        '903': 'Yes, we carried out work on infrastructure',
                                        '904': 'Yes, we carried out other construction work'}

        pck_transformer.parse_yes_no_questions()
        assert pck_transformer.data == {'901': '1',
                                        '902': '1',
                                        '903': '1',
                                        '904': '1'}

        # q code 902, 903, 904 no
        response = {'collection': {'instrument_id': '0001'}, 'data': {'901': 'Yes, I can report for this period',
                                                                      '902': 'No, we did not carry out work on housing',
                                                                      '903': 'No, we did not carry out work on infrastructure',
                                                                      '904': 'No, we did not carry out other construction work'}}
        pck_transformer = PCKTransformer(survey, response)
        assert pck_transformer.data == {'901': 'Yes, I can report for this period',
                                        '902': 'No, we did not carry out work on housing',
                                        '903': 'No, we did not carry out work on infrastructure',
                                        '904': 'No, we did not carry out other construction work'}

        pck_transformer.parse_yes_no_questions()
        assert pck_transformer.data == {'901': '1',
                                        '902': '2',
                                        '903': '2',
                                        '904': '2'}
        # q code 902, 903, 904 missing
        response = {'collection': {'instrument_id': '0001'}, 'data': {'901': 'Yes, I can report for this period'}}
        pck_transformer = PCKTransformer(survey, response)
        assert pck_transformer.data == {'901': 'Yes, I can report for this period'}
        pck_transformer.parse_yes_no_questions()
        assert pck_transformer.data == {'901': '1',
                                        '902': '2',
                                        '903': '2',
                                        '904': '2'}

        # q code 902, 903 no 904 yes
        response = {'collection': {'instrument_id': '0001'}, 'data': {'901': 'Yes, I can report for this period',
                                                                      '902': 'No, we did not carry out work on housing',
                                                                      '903': 'No, we did not carry out work on infrastructure',
                                                                      '904': 'Yes, we carried out other construction work'}}

        pck_transformer = PCKTransformer(survey, response)
        assert pck_transformer.data == {'901': 'Yes, I can report for this period',
                                        '902': 'No, we did not carry out work on housing',
                                        '903': 'No, we did not carry out work on infrastructure',
                                        '904': 'Yes, we carried out other construction work'}

        pck_transformer.parse_yes_no_questions()
        assert pck_transformer.data == {'901': '1',
                                        '902': '2',
                                        '903': '2',
                                        '904': '1'}