def test_record_cration_with_given_id(self, person_record: Record, client: Client): """ Create a new record with given id :param person_record: :param client: """ person_record.id = 199 person_record = client.records.create(person_record) assert_that(person_record, instance_of(Record)) assert_that(person_record.id, equal_to(199))
def test_new_record_can_be_retrieved_by_pk(self, person_record: Record, client: Client): """ Create a new record and check it has PK field assigned :param person_record: :param client: """ person_record.id = None person_record = client.records.create(person_record) assert_that( client.records.get(person_record.obj, person_record.get_pk()), instance_of(Record))
def test_new_record_is_created(self, person_record: Record, client: Client): """ Create a new record and check it has PK field assigned :param person_record: :param client: """ person_record.id = None assert_that(person_record.id, is_(None)) # create new record person_record = client.records.create(person_record) assert_that(person_record.id, instance_of(int))
def test_record_is_deleted(self, person_record: Record, client: Client): """ Delete the record and verify it does not exist in the database :param person_record: :param client: """ person_record.id = None assert_that(person_record.id, is_(None)) person_record = client.records.create(person_record) pk = person_record.get_pk() client.records.delete(person_record) assert_that(person_record.get_pk(), is_(None)) assert_that(client.records.get(person_record.obj, pk), is_(None))
def test_new_record_is_not_created_if_pk_is_duplicated( self, person_record: Record, client: Client): """ Try to create a new record with duplicated PK. Client should raise exception :param person_record: :param client: """ person_record.id = None assert_that(person_record.id, is_(None)) # create new record person_record = client.records.create(person_record) with pytest.raises(RecordAlreadyExistsException): client.records.create(person_record)
def test_record_is_updated(self, person_record: Record, client: Client): """ Change the record`s field value and store this change in the database :param person_record: :param client: """ person_record.id = None assert_that(person_record.id, is_(None)) person_record = client.records.create(person_record) new_name = 'Feodor' assert_that(new_name, not_(equal_to(person_record.name))) person_record.name = new_name person_record = client.records.update(person_record) assert_that(person_record.name, equal_to(new_name))
def test_client_returns_new_record_on_record_creation(person_record: Record, client: Client): person_record.id = None assert_that(person_record.exists(), is_not(True)) record_data = person_record.data record_data['id'] = 45 with requests_mock.Mocker() as mocker: mocker.post('/'.join( [client.server_url, 'data/{}'.format(person_record.obj)]), json={ 'status': 'OK', 'data': record_data }) record = client.records.create(person_record) assert_that(record, is_(instance_of(Record))) assert_that(record.exists()) assert_that(record.id, equal_to(45))