Exemple #1
0
def test_baseclient_write_open_neither_arg():
    from google.cloud.firestore_v1.base_client import _BAD_OPTION_ERR
    from google.cloud.firestore_v1.base_client import BaseClient

    with pytest.raises(TypeError) as exc_info:
        BaseClient.write_option()

    assert exc_info.value.args == (_BAD_OPTION_ERR, )
Exemple #2
0
def test_baseclient_write_bad_arg():
    from google.cloud.firestore_v1.base_client import _BAD_OPTION_ERR
    from google.cloud.firestore_v1.base_client import BaseClient

    with pytest.raises(TypeError) as exc_info:
        BaseClient.write_option(spinach="popeye")

    extra = "{!r} was provided".format("spinach")
    assert exc_info.value.args == (_BAD_OPTION_ERR, extra)
Exemple #3
0
def test_baseclient_write_multiple_args():
    from google.cloud.firestore_v1.base_client import _BAD_OPTION_ERR
    from google.cloud.firestore_v1.base_client import BaseClient

    with pytest.raises(TypeError) as exc_info:
        BaseClient.write_option(exists=False,
                                last_update_time=mock.sentinel.timestamp)

    assert exc_info.value.args == (_BAD_OPTION_ERR, )
Exemple #4
0
def test_baseclient_write_option_exists():
    from google.cloud.firestore_v1._helpers import ExistsOption
    from google.cloud.firestore_v1.base_client import BaseClient

    option1 = BaseClient.write_option(exists=False)
    assert isinstance(option1, ExistsOption)
    assert not option1._exists

    option2 = BaseClient.write_option(exists=True)
    assert isinstance(option2, ExistsOption)
    assert option2._exists
Exemple #5
0
def test_baseclient_write_option_last_update():
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1._helpers import LastUpdateOption
    from google.cloud.firestore_v1.base_client import BaseClient

    timestamp = timestamp_pb2.Timestamp(seconds=1299767599, nanos=811111097)

    option = BaseClient.write_option(last_update_time=timestamp)
    assert isinstance(option, LastUpdateOption)
    assert option._last_update_time == timestamp
Exemple #6
0
def test_baseclient_field_path():
    from google.cloud.firestore_v1.base_client import BaseClient

    assert BaseClient.field_path("a", "b", "c") == "a.b.c"
Exemple #7
0
def _make_base_client(*args, **kwargs):
    from google.cloud.firestore_v1.base_client import BaseClient

    return BaseClient(*args, **kwargs)