def test_update_with_diff(self): """ Should be able to update an employee after creating it and get a diff. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).create() with transaction(): _, diff = Employee( id=employee.id, last="Doe", ).update_with_diff() assert_that(list(diff.keys()), contains_inanyorder("last", "updated_at")) assert_that(diff["last"].before, is_(equal_to("last"))) assert_that(diff["last"].after, is_(equal_to("Doe"))) with transaction(): retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("first"))) assert_that(retrieved_employee.last, is_(equal_to("Doe"))) assert_that(Employee.count(), is_(equal_to(1)))
def test_update_with_diff(self): """ Should be able to update an employee after creating it and get a diff. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).create() with transaction(): _, diff = Employee( id=employee.id, last="Doe", ).update_with_diff() assert_that(list(diff.keys()), contains_inanyorder("last", "updated_at")) assert_that(diff["last"].before, is_(equal_to("last"))) assert_that(diff["last"].after, is_(equal_to("Doe"))) with transaction(): retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("first"))) assert_that(retrieved_employee.last, is_(equal_to("Doe"))) assert_that(Employee.count(), is_(equal_to(1)))
def test_update(self): """ Should be able to update an employee after creating it. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).create() with transaction(): updated_employee = Employee( id=employee.id, first="Jane", last="Doe", ).update() assert_that(updated_employee.first, is_(equal_to("Jane"))) assert_that(updated_employee.last, is_(equal_to("Doe"))) assert_that(updated_employee.company_id, is_(equal_to(self.company.id))) with transaction(): retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("Jane"))) assert_that(retrieved_employee.last, is_(equal_to("Doe"))) assert_that(Employee.count(), is_(equal_to(1)))
def test_update(self): """ Should be able to update an employee after creating it. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).create() with transaction(): updated_employee = Employee( id=employee.id, first="Jane", last="Doe", ).update() assert_that(updated_employee.first, is_(equal_to("Jane"))) assert_that(updated_employee.last, is_(equal_to("Doe"))) assert_that(updated_employee.company_id, is_(equal_to(self.company.id))) with transaction(): retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("Jane"))) assert_that(retrieved_employee.last, is_(equal_to("Doe"))) assert_that(Employee.count(), is_(equal_to(1)))
def test_create(self): """ Should be able to retrieve an employee after creating it. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).create() retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("first"))) assert_that(retrieved_employee.last, is_(equal_to("last")))
def test_create(self): """ Should be able to retrieve an employee after creating it. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).create() retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("first"))) assert_that(retrieved_employee.last, is_(equal_to("last")))
def test_replace_not_found(self): """ Should be able to replace an employee that does not exist. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).replace() with transaction(): retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("first"))) assert_that(retrieved_employee.last, is_(equal_to("last"))) assert_that(Employee.count(), is_(equal_to(1)))
def test_replace_not_found(self): """ Should be able to replace an employee that does not exist. """ with transaction(): employee = Employee( first="first", last="last", company_id=self.company.id, ).replace() with transaction(): retrieved_employee = Employee.retrieve(employee.id) assert_that(retrieved_employee.first, is_(equal_to("first"))) assert_that(retrieved_employee.last, is_(equal_to("last"))) assert_that(Employee.count(), is_(equal_to(1)))