Ejemplo n.º 1
0
 def __json__(self):
     return {
         JSON_MODEL_RUN_ID: self.id,
         JSON_USER_NAME: self.user.workbench_username,
         JSON_IS_PUBLISHED: self.status.is_published(),
         JSON_IS_PUBLIC: self.status.is_public(),
         JSON_LAST_STATUS_CHANGE: convert_time_to_standard_string(self.last_status_change)}
Ejemplo n.º 2
0
 def assert_model_run_json_is(self, model_run_json_dict, model_id, last_status_change, username, is_published, is_public):
     """
     assert that the model_run_json_dict has the expected answers
     :param model_run_json_dict: dictionary to check
     :param model_id: model id
     :param last_status_change: last status change
     :param username: the username who owns the model run
     :param is_published: whether model run is published
     :param is_public: whether model run is public
     :return: nothing
     :raises AssertionError: if the two don't match
     """
     assert_that(model_run_json_dict[JSON_MODEL_RUN_ID], is_(model_id), "model run id")
     assert_that(model_run_json_dict[JSON_USER_NAME], is_(username), "username")
     assert_that(model_run_json_dict[JSON_IS_PUBLISHED], is_(is_published), "the model is published")
     assert_that(model_run_json_dict[JSON_IS_PUBLIC], is_(is_public), "the model is public")
     assert_that(model_run_json_dict[JSON_LAST_STATUS_CHANGE], is_(convert_time_to_standard_string(last_status_change)), "last changed")
Ejemplo n.º 3
0
    def test_GIVEN_datetime_WHEN_convert_THEN_date_time_is_returned(self):
        datetime_to_convert = datetime(2001, 2, 3, 4, 5, 6, tzinfo=pytz.utc)
        result = convert_time_to_standard_string(datetime_to_convert)

        assert_that(result, is_("2001-02-03 04:05:06 +0000"))
Ejemplo n.º 4
0
    def test_GIVEN_datetime_with_no_time_zone_WHEN_convert_THEN_date_time_is_returned_as_if_utc(self):
        datetime_to_convert = datetime(2001, 2, 3, 4, 5, 6)
        result = convert_time_to_standard_string(datetime_to_convert)

        assert_that(result, is_("2001-02-03 04:05:06 +0000"))
Ejemplo n.º 5
0
    def test_GIVEN_none_WHEN_convert_THEN_empty_string_returned(self):

        result = convert_time_to_standard_string(None)

        assert_that(result, is_(""))