def test_load_survey_miss(self):
     ids = Survey.identifiers({
         "survey_id": "127",
         "tx_id": "27923934-62de-475c-bc01-433c09fd38b8",
         "collection": {
             "instrument_id": "0001",
             "period": "201704"
         },
         "metadata": {
             "user_id": "123456789",
             "ru_ref": "12345678901A"
         }
     })
     with pytest.raises(MissingSurveyException):
         Survey.load_survey(ids, "./tests/data/{survey_id}.{inst_id}.json")
Exemple #2
0
    def test_load_survey_miss(self):
        """
        Tests if load data is missed if survey id is not 134

        """
        ids = Survey.identifiers({
            "survey_id": "127",
            "tx_id": "27923934-62de-475c-bc01-433c09fd38b8",
            "collection": {
                "instrument_id": "0001",
                "period": "201704"
            },
            "metadata": {
                "user_id": "123456789",
                "ru_ref": "12345678901A"
            }
        }, batch_nr=0, seq_nr=0)

        with pytest.raises(MissingSurveyException):
            Survey.load_survey(ids, MWSSTransformer.pattern)
Exemple #3
0
 def __init__(self, response, sequence_no):
     self.response = response
     self.sequence_no = sequence_no
     self.logger = logger
     self.ids = Survey.identifiers(response, seq_nr=sequence_no)
     self.survey = Survey.load_survey(self.ids)
     self.image_transformer = ImageTransformer(
         self.logger,
         self.survey,
         self.response,
         sequence_no=self.sequence_no,
         base_image_path=SDX_FTP_IMAGE_PATH)
 def test_load_survey_miss(self):
     ids = Survey.identifiers({
         "survey_id": "127",
         "tx_id": "27923934-62de-475c-bc01-433c09fd38b8",
         "collection": {
             "instrument_id": "0001",
             "period": "201704"
         },
         "metadata": {
             "user_id": "123456789",
             "ru_ref": "12345678901A"
         }
     })
     rv = Survey.load_survey(ids, "./tests/data/{survey_id}.{inst_id}.json")
     self.assertIsNone(rv)
 def test_load_survey(self):
     ids = Survey.identifiers({
         "survey_id": "134",
         "tx_id": "27923934-62de-475c-bc01-433c09fd38b8",
         "collection": {
             "instrument_id": "0005",
             "period": "201704"
         },
         "metadata": {
             "user_id": "123456789",
             "ru_ref": "12345678901A"
         }
     })
     rv = Survey.load_survey(ids, "./tests/data/{survey_id}.{inst_id}.json")
     self.assertIsNotNone(rv)
    def test_load_survey_miss(self):
        """
        Tests if load data is missed if survey id is not 134

        """
        ids = Survey.identifiers({
            "survey_id": "127",
            "tx_id": "27923934-62de-475c-bc01-433c09fd38b8",
            "collection": {
                "instrument_id": "0001",
                "period": "201704"
            },
            "metadata": {
                "user_id": "123456789",
                "ru_ref": "12345678901A"
            }
        }, batch_nr=0, seq_nr=0)
        return_value = Survey.load_survey(ids, MWSSTransformer.pattern)
        self.assertIsNone(return_value)
Exemple #7
0
    def test_load_survey(self):
        """
        Tests if load data passes if survey id is 134

        """
        ids = Survey.identifiers({
            "survey_id": "134",
            "tx_id": "27923934-62de-475c-bc01-433c09fd38b8",
            "collection": {
                "instrument_id": "0005",
                "period": "201704"
            },
            "metadata": {
                "user_id": "123456789",
                "ru_ref": "12345678901A"
            }
        }, batch_nr=0, seq_nr=0)
        return_value = Survey.load_survey(ids, MWSSTransformer.pattern)
        self.assertIsNotNone(return_value)
    def __init__(self, response, seq_nr=0, log=None):
        """Create a transformer object to process a survey response."""
        self.response = response
        self.ids = Survey.identifiers(response, seq_nr=seq_nr)

        if self.ids is None:
            raise UserWarning("Missing identifiers")

        if log is None:
            self.log = wrap_logger(logging.getLogger(__name__))
        else:
            self.log = Survey.bind_logger(log, self.ids)

        # Enforce that child classes have defn and pattern attributes
        for attr in ("defn", "pattern"):
            if not hasattr(self.__class__, attr):
                raise UserWarning("Missing class attribute: {0}".format(attr))

        self.survey = Survey.load_survey(self.ids, self.pattern)
        self.image_transformer = ImageTransformer(self.log, self.survey, self.response,
                                                  sequence_no=self.ids.seq_nr, base_image_path=SDX_FTP_IMAGE_PATH)