Ejemplo n.º 1
0
 def test_it_handles_list_job_start_at_qs(self, table, k):
     stub = job_stub()
     table.query.return_value = {"Items": [stub]}
     handlers.list_jobs_handler(
         {"queryStringParameters": {
             "start_at": "12345"
         }}, SimpleNamespace())
     k.assert_called_with("CreatedAt")
     k().lt.assert_called_with(12345)
Ejemplo n.º 2
0
 def test_it_returns_requested_page_size_for_jobs(self, table):
     stub = job_stub()
     table.query.return_value = {"Items": [stub for _ in range(0, 3)]}
     handlers.list_jobs_handler(
         {"queryStringParameters": {
             "page_size": "3"
         }}, SimpleNamespace())
     table.query.assert_called_with(IndexName=ANY,
                                    KeyConditionExpression=ANY,
                                    ScanIndexForward=ANY,
                                    Limit=3,
                                    ProjectionExpression=ANY)
Ejemplo n.º 3
0
 def test_it_rejects_invalid_page_size_for_list_jobs(self):
     response = handlers.list_jobs_handler(
         {"queryStringParameters": {
             "page_size": "NaN"
         }}, SimpleNamespace())
     assert 422 == response["statusCode"]
     response = handlers.list_jobs_handler(
         {"queryStringParameters": {
             "page_size": "0"
         }}, SimpleNamespace())
     assert 422 == response["statusCode"]
     response = handlers.list_jobs_handler(
         {"queryStringParameters": {
             "page_size": "1001"
         }}, SimpleNamespace())
     assert 422 == response["statusCode"]
Ejemplo n.º 4
0
 def test_it_rejects_invalid_start_at_for_list_jobs(self, table):
     stub = job_stub()
     table.query.return_value = {"Items": [stub for _ in range(0, 3)]}
     response = handlers.list_jobs_handler(
         {"queryStringParameters": {
             "page_size": "badformat"
         }}, SimpleNamespace())
     assert 422 == response["statusCode"]
Ejemplo n.º 5
0
 def test_it_returns_requested_page_size_for_jobs_with_multiple_gsi_buckets(
         self, table):
     table.query.return_value = {"Items": [job_stub() for _ in range(0, 5)]}
     resp = handlers.list_jobs_handler(
         {"queryStringParameters": {
             "page_size": "5"
         }}, SimpleNamespace())
     assert 3 == table.query.call_count
     assert 5 == len(json.loads(resp["body"])["Jobs"])
Ejemplo n.º 6
0
 def test_it_lists_jobs(self, table):
     stub = job_stub()
     table.query.return_value = {"Items": [stub]}
     response = handlers.list_jobs_handler({"queryStringParameters": None},
                                           SimpleNamespace())
     resp_body = json.loads(response["body"])
     assert 200 == response["statusCode"]
     assert 1 == len(resp_body["Jobs"])
     assert stub == resp_body["Jobs"][0]
Ejemplo n.º 7
0
 def test_it_queries_all_gsi_buckets(self, table):
     stub = job_stub()
     table.query.return_value = {"Items": [stub]}
     handlers.list_jobs_handler({"queryStringParameters": None},
                                SimpleNamespace())
     assert 3 == table.query.call_count
Ejemplo n.º 8
0
 def test_it_rejects_invalid_start_at_for_list_jobs(self):
     response = handlers.list_jobs_handler(
         {"queryStringParameters": {
             "start_at": "badformat"
         }}, SimpleNamespace())
     assert 422 == response["statusCode"]