Пример #1
0
  def test_update_if_dirty(self):
    """
    Tests that update_if_dirty works.
    We use the last_modified field as a proxy for knowing
    whether or not we actually did a save.
    """
    create_tables(TestModel)
    x = TestModel()
    x.my_int = 3
    x.my_string = "foo"
    x.save()
    last_mod = x.last_modified

    django_util.update_if_dirty(x, my_int=3, my_string="bar")
    assert_not_equal(x.last_modified, last_mod)
    last_mod = x.last_modified

    django_util.update_if_dirty(x, my_int=3, my_string="bar")
    assert_equal(x.last_modified, last_mod)

    x.delete()
Пример #2
0
  def test_update_if_dirty(self):
    """
    Tests that update_if_dirty works.
    We use the last_modified field as a proxy for knowing
    whether or not we actually did a save.
    """
    create_tables(TestModel)
    x = TestModel()
    x.my_int = 3
    x.my_string = "foo"
    x.save()
    last_mod = x.last_modified

    django_util.update_if_dirty(x, my_int=3, my_string="bar")
    assert_not_equal(x.last_modified, last_mod)
    last_mod = x.last_modified

    django_util.update_if_dirty(x, my_int=3, my_string="bar")
    assert_equal(x.last_modified, last_mod)

    x.delete()