@@ -504,14 +504,14 @@ def test_date():
504
504
F .insert1 ((2 , "2019-09-25" ))
505
505
506
506
new_value = None
507
- ( F & "id=2" )._update ( "date" , new_value )
507
+ F . update1 ( dict (( F & "id=2" ).proj (). fetch1 (), date = new_value ) )
508
508
assert_equal ((F & "id=2" ).fetch1 ("date" ), new_value )
509
509
510
510
new_value = datetime .date (2019 , 10 , 25 )
511
- ( F & "id=2" )._update ( "date" , new_value )
511
+ F . update1 ( dict (( F & "id=2" ).proj (). fetch1 (), date = new_value ) )
512
512
assert_equal ((F & "id=2" ).fetch1 ("date" ), new_value )
513
513
514
- ( F & "id=2" )._update ( " date" )
514
+ F . update1 ( dict (( F & "id=2" ).proj (). fetch1 (), date = None ) )
515
515
assert_equal ((F & "id=2" ).fetch1 ("date" ), None )
516
516
517
517
@staticmethod
@@ -532,19 +532,21 @@ def test_ellipsis():
532
532
@raises (dj .DataJointError )
533
533
def test_update_single_key ():
534
534
"""Test that only one row can be updated"""
535
- TTestUpdate ()._update ("string_attr" , "my new string" )
535
+ TTestUpdate .update1 (
536
+ dict (TTestUpdate .proj ().fetch1 (), string_attr = "my new string" )
537
+ )
536
538
537
539
@staticmethod
538
540
@raises (dj .DataJointError )
539
541
def test_update_no_primary ():
540
542
"""Test that no primary key can be updated"""
541
- TTestUpdate (). _update ( "primary_key" , 2 )
543
+ TTestUpdate . update1 ( dict ( TTestUpdate . proj (). fetch1 (), primary_key = 2 ) )
542
544
543
545
@staticmethod
544
546
@raises (dj .DataJointError )
545
547
def test_update_missing_attribute ():
546
548
"""Test that attribute is in table"""
547
- TTestUpdate (). _update ( "not_existing" , 2 )
549
+ TTestUpdate . update1 ( dict ( TTestUpdate . proj (). fetch1 (), not_existing = 2 ) )
548
550
549
551
@staticmethod
550
552
def test_update_string_attribute ():
@@ -553,25 +555,25 @@ def test_update_string_attribute():
553
555
s = "" .join (
554
556
random .choice (string .ascii_uppercase + string .digits ) for _ in range (10 )
555
557
)
556
- rel ._update ( "string_attr" , s )
558
+ TTestUpdate . update1 ( dict ( rel .proj (). fetch1 (), string_attr = s ) )
557
559
assert_equal (s , rel .fetch1 ("string_attr" ), "Updated string does not match" )
558
560
559
561
@staticmethod
560
562
def test_update_numeric_attribute ():
561
563
"""Test replacing a string value"""
562
564
rel = TTestUpdate () & dict (primary_key = 0 )
563
565
s = random .randint (0 , 10 )
564
- rel ._update ( "num_attr" , s )
566
+ TTestUpdate . update1 ( dict ( rel .proj (). fetch1 (), num_attr = s ) )
565
567
assert_equal (s , rel .fetch1 ("num_attr" ), "Updated integer does not match" )
566
- rel ._update ( "num_attr" , None )
568
+ TTestUpdate . update1 ( dict ( rel .proj (). fetch1 (), num_attr = None ) )
567
569
assert_true (np .isnan (rel .fetch1 ("num_attr" )), "Numeric value is not NaN" )
568
570
569
571
@staticmethod
570
572
def test_update_blob_attribute ():
571
573
"""Test replacing a string value"""
572
574
rel = TTestUpdate () & dict (primary_key = 0 )
573
575
s = rel .fetch1 ("blob_attr" )
574
- rel ._update ( "blob_attr" , s .T )
576
+ TTestUpdate . update1 ( dict ( rel .proj (). fetch1 (), blob_attr = s .T ) )
575
577
assert_equal (
576
578
s .T .shape , rel .fetch1 ("blob_attr" ).shape , "Array dimensions do not match"
577
579
)
0 commit comments