<s> from __future__ import unicode_literals <EOL> from reviewboard . changedescs . models import ChangeDescription <EOL> from reviewboard . testing . testcase import TestCase <EOL> class ChangeDescTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_record_string ( self ) : <EOL> """<STR_LIT>""" <EOL> old_value = "<STR_LIT:abc>" <EOL> new_value = "<STR_LIT>" <EOL> changedesc = ChangeDescription ( ) <EOL> changedesc . record_field_change ( "<STR_LIT:test>" , old_value , new_value ) <EOL> self . assertIn ( "<STR_LIT:test>" , changedesc . fields_changed ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertNotIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertNotIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertEqual ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] , <EOL> ( old_value , ) ) <EOL> self . assertEqual ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] , <EOL> ( new_value , ) ) <EOL> def test_record_list ( self ) : <EOL> """<STR_LIT>""" <EOL> old_value = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> new_value = [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> changedesc = ChangeDescription ( ) <EOL> changedesc . record_field_change ( "<STR_LIT:test>" , old_value , new_value ) <EOL> self . assertIn ( "<STR_LIT:test>" , changedesc . fields_changed ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertEqual ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] , <EOL> [ ( i , ) for i in old_value ] ) <EOL> self . assertEqual ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] , <EOL> [ ( i , ) for i in new_value ] ) <EOL> self . assertEqual ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] , [ ( <NUM_LIT:4> , ) ] ) <EOL> self . assertEqual ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] , [ ( <NUM_LIT:1> , ) ] ) <EOL> def test_record_object_list_name_field ( self ) : <EOL> """<STR_LIT>""" <EOL> class DummyObject ( object ) : <EOL> def __init__ ( self , id ) : <EOL> self . id = id <EOL> self . text = "<STR_LIT>" % id <EOL> def get_absolute_url ( self ) : <EOL> return "<STR_LIT>" % self . id <EOL> objs = [ DummyObject ( i ) for i in range ( <NUM_LIT:4> ) ] <EOL> old_value = [ objs [ <NUM_LIT:0> ] , objs [ <NUM_LIT:1> ] , objs [ <NUM_LIT:2> ] ] <EOL> new_value = [ objs [ <NUM_LIT:1> ] , objs [ <NUM_LIT:2> ] , objs [ <NUM_LIT:3> ] ] <EOL> changedesc = ChangeDescription ( ) <EOL> changedesc . record_field_change ( "<STR_LIT:test>" , old_value , new_value , "<STR_LIT:text>" ) <EOL> self . assertIn ( "<STR_LIT:test>" , changedesc . fields_changed ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , changedesc . fields_changed [ "<STR_LIT:test>" ] ) <EOL> self . assertEqual ( set ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] ) , <EOL> set ( [ ( obj . text , obj . get_absolute_url ( ) , obj . id ) <EOL> for obj in old_value ] ) ) <EOL> self . assertEqual ( set ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] ) , <EOL> set ( [ ( obj . text , obj . get_absolute_url ( ) , obj . id ) <EOL> for obj in new_value ] ) ) <EOL> self . assertEqual ( set ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] ) , <EOL> set ( [ ( new_value [ <NUM_LIT:2> ] . text , <EOL> new_value [ <NUM_LIT:2> ] . get_absolute_url ( ) , <EOL> new_value [ <NUM_LIT:2> ] . id ) ] ) ) <EOL> self . assertEqual ( set ( changedesc . fields_changed [ "<STR_LIT:test>" ] [ "<STR_LIT>" ] ) , <EOL> set ( [ ( old_value [ <NUM_LIT:0> ] . text , <EOL> old_value [ <NUM_LIT:0> ] . get_absolute_url ( ) , <EOL> old_value [ <NUM_LIT:0> ] . id ) ] ) ) <EOL> def test_record_list_mismatch_type ( self ) : <EOL> """<STR_LIT>""" <EOL> changedesc = ChangeDescription ( ) <EOL> self . assertRaises ( ValueError , <EOL> changedesc . record_field_change , <EOL> "<STR_LIT:test>" , <NUM_LIT> , True ) </s>
