Exemple #1
0
 def test_push_content(self):
     self.create()
     storage.push_content(self.bucket, "mykey.txt", "Hey Jude")
     bucket = self.conn.get_bucket(self.bucket)
     self.assertEqual(
         bucket.get_key("mykey.txt").get_contents_as_string(
             encoding='utf-8'), "Hey Jude")
Exemple #2
0
 def test_get_steps_done(self):
     self.create_bucket()
     storage.push_content(BUCKET, "steps/mystep", "data")
     storage.push_content(BUCKET, "steps/mystep2", "data")
     t = GetStepsDoneTask(BUCKET, "steps")
     res = t.execute()
     self.assertEqual(res, ["mystep", "mystep2"])
Exemple #3
0
 def test_get_steps_done(self):
     self.create_bucket()
     storage.push_content(BUCKET, "steps/mystep", "data")
     storage.push_content(BUCKET, "steps/mystep2", "data")
     t = GetStepsDoneTask(BUCKET, "steps")
     res = t.execute()
     self.assertEqual(res, ["mystep", "mystep2"])
 def test_push_content(self):
     self.create()
     storage.push_content(self.bucket, "mykey.txt", "Hey Jude")
     bucket = self.conn.get_bucket(self.bucket)
     self.assertEqual(
         bucket.get_key("mykey.txt").get_contents_as_string(
             encoding='utf-8'),
         "Hey Jude")
Exemple #5
0
 def execute(self):
     path = os.path.join(self.path, self.step_name)
     if hasattr(self, 'context'):
         context = self.context
         content = {
             "run_id": context["run_id"],
             "workflow_id": context["workflow_id"],
             "version": context["version"]
         }
     else:
         content = UNKNOWN_CONTEXT
     storage.push_content(self.bucket, path, json.dumps(content))
Exemple #6
0
 def execute(self):
     path = os.path.join(self.path, self.step_name)
     if hasattr(self, 'context'):
         context = self.context
         content = {
             "run_id": context["run_id"],
             "workflow_id": context["workflow_id"],
             "version": context["version"]
         }
     else:
         content = UNKNOWN_CONTEXT
     storage.push_content(self.bucket, path, json.dumps(content))
    def test_decode(self):
        self.setup_jumbo_fields("jumbo-bucket")
        push_content("jumbo-bucket", "abc", "decoded jumbo field yay!")

        cases = [
            [None,                                  None],
            ["foo bar baz",                         "foo bar baz"],
            ['"a string"',                          "a string"],
            ['[1, 2]',                              [1, 2]],
            ["simpleflow+s3://jumbo-bucket/abc 24", "decoded jumbo field yay!"],
        ]

        for case in cases:
            self.assertEqual(case[1], format.decode(case[0]))
Exemple #8
0
    def test_decode_no_parse_json(self):
        self.setup_jumbo_fields("jumbo-bucket")
        push_content("jumbo-bucket", "abc", "decoded jumbo field yay!")

        cases = [
            [None,                                  None],
            ["foo bar baz",                         "foo bar baz"],
            ['"a string"',                          '"a string"'],
            ['[1, 2]',                              "[1, 2]"],
            ["simpleflow+s3://jumbo-bucket/abc 24", "decoded jumbo field yay!"],
        ]

        for case in cases:
            self.assertEqual(case[1], format.decode(case[0], parse_json=False))
Exemple #9
0
def _push_jumbo_field(message):
    size = len(message)
    uuid = str(uuid4())
    bucket_with_dir = _jumbo_fields_bucket()
    if "/" in bucket_with_dir:
        bucket, directory = _jumbo_fields_bucket().split("/", 1)
        path = "{}/{}".format(directory, uuid)
    else:
        bucket = bucket_with_dir
        path = uuid

    storage.push_content(bucket, path, message)
    _set_cached(path, message)

    return "{}{}/{} {}".format(constants.JUMBO_FIELDS_PREFIX, bucket, path, size)
    def test_task_failed_jumbo_fields_resolution(self):
        # prepare jumbo field content
        boto.connect_s3().create_bucket("jumbo-bucket")
        push_content("jumbo-bucket", "my-reason", "reason decoded!")
        push_content("jumbo-bucket", "my-details", "details decoded!")

        # test resolution
        failure = TaskFailed("message",
                             "simpleflow+s3://jumbo-bucket/my-reason 17",
                             "simpleflow+s3://jumbo-bucket/my-details 17")
        # TODO: maybe override __str__() ourselves to get rid of those ugly u'' in python 2.x
        expect(str(failure)).to.match(
            r"^\('message', u?'reason decoded!', u?'details decoded!'\)$")
        expect(
            repr(failure)).to.equal('TaskFailed (message, "reason decoded!")')
    def test_task_failed_jumbo_fields_resolution(self):
        # prepare jumbo field content
        boto.connect_s3().create_bucket("jumbo-bucket")
        push_content("jumbo-bucket", "my-reason", "reason decoded!")
        push_content("jumbo-bucket", "my-details", "details decoded!")

        # test resolution
        failure = TaskFailed(
            "message",
            "simpleflow+s3://jumbo-bucket/my-reason 17",
            "simpleflow+s3://jumbo-bucket/my-details 17"
        )
        # TODO: maybe override __str__() ourselves to get rid of those ugly u'' in python 2.x
        expect(str(failure)).to.match(r"^\('message', u?'reason decoded!', u?'details decoded!'\)$")
        expect(repr(failure)).to.equal('TaskFailed (message, "reason decoded!")')
Exemple #12
0
def _push_jumbo_field(message):
    size = len(message)
    uuid = str(uuid4())
    bucket_with_dir = _jumbo_fields_bucket()
    if "/" in bucket_with_dir:
        bucket, directory = _jumbo_fields_bucket().split("/", 1)
        path = "{}/{}".format(directory, uuid)
    else:
        bucket = bucket_with_dir
        path = uuid

    storage.push_content(bucket, path, message)
    _set_cached(path, message)

    return "{}{}/{} {}".format(constants.JUMBO_FIELDS_PREFIX, bucket, path,
                               size)