File: test_server.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (35 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from urllib.parse import urlencode

import moto.server as server


def test_list_databases():
    backend = server.create_backend_app("rds")
    test_client = backend.test_client()

    res = test_client.get("/?Action=DescribeDBInstances")

    assert "<DescribeDBInstancesResult>" in res.data.decode("utf-8")


def test_create_db_instance():
    backend = server.create_backend_app("rds")
    test_client = backend.test_client()
    params = {
        "Action": "CreateDBInstance",
        "DBInstanceIdentifier": "hi",
        "DBInstanceClass": "db.m4.large",
        "Engine": "postgres",
        "StorageType": "standard",
        "Port": 5432,
    }
    qs = urlencode(params)
    resp = test_client.post(f"/?{qs}")
    response = resp.data.decode("utf-8")
    assert "<DBClusterIdentifier>" not in response
    assert "<DBInstanceIdentifier>hi</DBInstanceIdentifier" in response
    # We do not pass these values - they should default to false
    assert "<MultiAZ>false</MultiAZ>" in response
    assert (
        "<IAMDatabaseAuthenticationEnabled>false</IAMDatabaseAuthenticationEnabled>"
    ) in response