Adjust tests to work in server mode
This commit is contained in:
parent
03fd04db33
commit
a67660b8a4
@ -1,11 +1,9 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
import pytz
|
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from freezegun import freeze_time
|
|
||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
|
||||||
from moto import mock_codepipeline, mock_iam
|
from moto import mock_codepipeline, mock_iam
|
||||||
@ -347,7 +345,6 @@ def test_create_pipeline_errors():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@freeze_time("2019-01-01 12:00:00")
|
|
||||||
@mock_codepipeline
|
@mock_codepipeline
|
||||||
def test_get_pipeline():
|
def test_get_pipeline():
|
||||||
client = boto3.client("codepipeline", region_name="us-east-1")
|
client = boto3.client("codepipeline", region_name="us-east-1")
|
||||||
@ -452,13 +449,11 @@ def test_get_pipeline():
|
|||||||
"version": 1,
|
"version": 1,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
response["metadata"].should.equal(
|
response["metadata"]["pipelineArn"].should.equal(
|
||||||
{
|
"arn:aws:codepipeline:us-east-1:123456789012:test-pipeline"
|
||||||
"pipelineArn": "arn:aws:codepipeline:us-east-1:123456789012:test-pipeline",
|
|
||||||
"created": datetime.now(pytz.utc),
|
|
||||||
"updated": datetime.now(pytz.utc),
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
response["metadata"]["created"].should.be.a(datetime)
|
||||||
|
response["metadata"]["updated"].should.be.a(datetime)
|
||||||
|
|
||||||
|
|
||||||
@mock_codepipeline
|
@mock_codepipeline
|
||||||
@ -480,102 +475,102 @@ def test_get_pipeline_errors():
|
|||||||
def test_update_pipeline():
|
def test_update_pipeline():
|
||||||
client = boto3.client("codepipeline", region_name="us-east-1")
|
client = boto3.client("codepipeline", region_name="us-east-1")
|
||||||
role_arn = get_role_arn()
|
role_arn = get_role_arn()
|
||||||
with freeze_time("2019-01-01 12:00:00"):
|
client.create_pipeline(
|
||||||
created_time = datetime.now(pytz.utc)
|
pipeline={
|
||||||
client.create_pipeline(
|
"name": "test-pipeline",
|
||||||
pipeline={
|
"roleArn": role_arn,
|
||||||
"name": "test-pipeline",
|
"artifactStore": {
|
||||||
"roleArn": role_arn,
|
"type": "S3",
|
||||||
"artifactStore": {
|
"location": "codepipeline-us-east-1-123456789012",
|
||||||
"type": "S3",
|
|
||||||
"location": "codepipeline-us-east-1-123456789012",
|
|
||||||
},
|
|
||||||
"stages": [
|
|
||||||
{
|
|
||||||
"name": "Stage-1",
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"name": "Action-1",
|
|
||||||
"actionTypeId": {
|
|
||||||
"category": "Source",
|
|
||||||
"owner": "AWS",
|
|
||||||
"provider": "S3",
|
|
||||||
"version": "1",
|
|
||||||
},
|
|
||||||
"configuration": {
|
|
||||||
"S3Bucket": "test-bucket",
|
|
||||||
"S3ObjectKey": "test-object",
|
|
||||||
},
|
|
||||||
"outputArtifacts": [{"name": "artifact"},],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Stage-2",
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"name": "Action-1",
|
|
||||||
"actionTypeId": {
|
|
||||||
"category": "Approval",
|
|
||||||
"owner": "AWS",
|
|
||||||
"provider": "Manual",
|
|
||||||
"version": "1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
tags=[{"key": "key", "value": "value"}],
|
"stages": [
|
||||||
)
|
{
|
||||||
|
"name": "Stage-1",
|
||||||
with freeze_time("2019-01-02 12:00:00"):
|
"actions": [
|
||||||
updated_time = datetime.now(pytz.utc)
|
{
|
||||||
response = client.update_pipeline(
|
"name": "Action-1",
|
||||||
pipeline={
|
"actionTypeId": {
|
||||||
"name": "test-pipeline",
|
"category": "Source",
|
||||||
"roleArn": role_arn,
|
"owner": "AWS",
|
||||||
"artifactStore": {
|
"provider": "S3",
|
||||||
"type": "S3",
|
"version": "1",
|
||||||
"location": "codepipeline-us-east-1-123456789012",
|
},
|
||||||
|
"configuration": {
|
||||||
|
"S3Bucket": "test-bucket",
|
||||||
|
"S3ObjectKey": "test-object",
|
||||||
|
},
|
||||||
|
"outputArtifacts": [{"name": "artifact"},],
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
"stages": [
|
{
|
||||||
{
|
"name": "Stage-2",
|
||||||
"name": "Stage-1",
|
"actions": [
|
||||||
"actions": [
|
{
|
||||||
{
|
"name": "Action-1",
|
||||||
"name": "Action-1",
|
"actionTypeId": {
|
||||||
"actionTypeId": {
|
"category": "Approval",
|
||||||
"category": "Source",
|
"owner": "AWS",
|
||||||
"owner": "AWS",
|
"provider": "Manual",
|
||||||
"provider": "S3",
|
"version": "1",
|
||||||
"version": "1",
|
|
||||||
},
|
|
||||||
"configuration": {
|
|
||||||
"S3Bucket": "different-bucket",
|
|
||||||
"S3ObjectKey": "test-object",
|
|
||||||
},
|
|
||||||
"outputArtifacts": [{"name": "artifact"},],
|
|
||||||
},
|
},
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
{
|
},
|
||||||
"name": "Stage-2",
|
],
|
||||||
"actions": [
|
},
|
||||||
{
|
tags=[{"key": "key", "value": "value"}],
|
||||||
"name": "Action-1",
|
)
|
||||||
"actionTypeId": {
|
|
||||||
"category": "Approval",
|
response = client.get_pipeline(name="test-pipeline")
|
||||||
"owner": "AWS",
|
created_time = response["metadata"]["created"]
|
||||||
"provider": "Manual",
|
updated_time = response["metadata"]["updated"]
|
||||||
"version": "1",
|
|
||||||
},
|
response = client.update_pipeline(
|
||||||
|
pipeline={
|
||||||
|
"name": "test-pipeline",
|
||||||
|
"roleArn": role_arn,
|
||||||
|
"artifactStore": {
|
||||||
|
"type": "S3",
|
||||||
|
"location": "codepipeline-us-east-1-123456789012",
|
||||||
|
},
|
||||||
|
"stages": [
|
||||||
|
{
|
||||||
|
"name": "Stage-1",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"name": "Action-1",
|
||||||
|
"actionTypeId": {
|
||||||
|
"category": "Source",
|
||||||
|
"owner": "AWS",
|
||||||
|
"provider": "S3",
|
||||||
|
"version": "1",
|
||||||
},
|
},
|
||||||
],
|
"configuration": {
|
||||||
},
|
"S3Bucket": "different-bucket",
|
||||||
],
|
"S3ObjectKey": "test-object",
|
||||||
}
|
},
|
||||||
)
|
"outputArtifacts": [{"name": "artifact"},],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Stage-2",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"name": "Action-1",
|
||||||
|
"actionTypeId": {
|
||||||
|
"category": "Approval",
|
||||||
|
"owner": "AWS",
|
||||||
|
"provider": "Manual",
|
||||||
|
"version": "1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
response["pipeline"].should.equal(
|
response["pipeline"].should.equal(
|
||||||
{
|
{
|
||||||
@ -630,14 +625,9 @@ def test_update_pipeline():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
response = client.get_pipeline(name="test-pipeline")
|
metadata = client.get_pipeline(name="test-pipeline")["metadata"]
|
||||||
response["metadata"].should.equal(
|
metadata["created"].should.equal(created_time)
|
||||||
{
|
metadata["updated"].should.be.greater_than(updated_time)
|
||||||
"pipelineArn": "arn:aws:codepipeline:us-east-1:123456789012:test-pipeline",
|
|
||||||
"created": created_time,
|
|
||||||
"updated": updated_time,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_codepipeline
|
@mock_codepipeline
|
||||||
@ -699,7 +689,6 @@ def test_update_pipeline_errors():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@freeze_time("2019-01-01 12:00:00")
|
|
||||||
@mock_codepipeline
|
@mock_codepipeline
|
||||||
def test_list_pipelines():
|
def test_list_pipelines():
|
||||||
client = boto3.client("codepipeline", region_name="us-east-1")
|
client = boto3.client("codepipeline", region_name="us-east-1")
|
||||||
@ -796,25 +785,17 @@ def test_list_pipelines():
|
|||||||
|
|
||||||
response = client.list_pipelines()
|
response = client.list_pipelines()
|
||||||
|
|
||||||
response["pipelines"].should.equal(
|
response["pipelines"].should.have.length_of(2)
|
||||||
[
|
response["pipelines"][0]["name"].should.equal("test-pipeline-1")
|
||||||
{
|
response["pipelines"][0]["version"].should.equal(1)
|
||||||
"name": "test-pipeline-1",
|
response["pipelines"][0]["created"].should.be.a(datetime)
|
||||||
"version": 1,
|
response["pipelines"][0]["updated"].should.be.a(datetime)
|
||||||
"created": datetime.now(pytz.utc),
|
response["pipelines"][1]["name"].should.equal("test-pipeline-2")
|
||||||
"updated": datetime.now(pytz.utc),
|
response["pipelines"][1]["version"].should.equal(1)
|
||||||
},
|
response["pipelines"][1]["created"].should.be.a(datetime)
|
||||||
{
|
response["pipelines"][1]["updated"].should.be.a(datetime)
|
||||||
"name": "test-pipeline-2",
|
|
||||||
"version": 1,
|
|
||||||
"created": datetime.now(pytz.utc),
|
|
||||||
"updated": datetime.now(pytz.utc),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@freeze_time("2019-01-01 12:00:00")
|
|
||||||
@mock_codepipeline
|
@mock_codepipeline
|
||||||
def test_delete_pipeline():
|
def test_delete_pipeline():
|
||||||
client = boto3.client("codepipeline", region_name="us-east-1")
|
client = boto3.client("codepipeline", region_name="us-east-1")
|
||||||
@ -863,16 +844,7 @@ def test_delete_pipeline():
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
client.list_pipelines()["pipelines"].should.equal(
|
client.list_pipelines()["pipelines"].should.have.length_of(1)
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "test-pipeline",
|
|
||||||
"version": 1,
|
|
||||||
"created": datetime.now(pytz.utc),
|
|
||||||
"updated": datetime.now(pytz.utc),
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
client.delete_pipeline(name="test-pipeline")
|
client.delete_pipeline(name="test-pipeline")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user